Datasets:
| # Open the original file for reading | |
| with open('english_basque_dictionary.txt', 'r', encoding='utf-8') as file: | |
| lines = file.readlines() | |
| # Create two new files for writing | |
| with open('dictionary.en-eu.en', 'w', encoding='utf-8') as english_file, \ | |
| open('dictionary.en-eu.eu', 'w', encoding='utf-8') as basque_file: | |
| # Iterate through each line in the original file | |
| for line in lines: | |
| # Split the line into English word and Basque translation | |
| english, basque = line.strip().split('\t') | |
| # Write the English word to the English file | |
| english_file.write(english + '\n') | |
| # Write the Basque translation to the Basque file | |
| basque_file.write(basque + '\n') | |
| print("Files separated successfully!") | |