I'm opening text file in encoding UTF-16
mode:
with open(file.txt, 'r', encoding="UTF-16") as infile:
Then I want to write to an excel file:
from csv import writer
excelFile = open("excelFile_1.csv", 'w', newline='')
write = writer(excelFile, delimiter=',')
write.writerows([[input]])
where input
is a term from the text file file.txt
I get the following error
UnicodeEncodeError: 'charmap' codec can't encode character '\xe9' in position 113: character maps to <undefined>
Using Python 3.2