The below problem is temporarily fixed. I figured out that the input file (csv) has special characters (e.g. Aimí©) that resulted in the error. I now manually change the characters (e.g. Aimí© --> Aime).
Previous question:
I am using unicodecsv
while writing to a csv file. My program ran smoothly until I encountered the below error. Could someone help?
Code:
import unicodecsv as csv
output_csv_write = open(csv_file_name_write,'w')
csv_file_write = csv.writer(output_csv_write, encoding='utf-8')
csv_file_write.writerow([An array of info])
First error:
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 3-4: unexpected end of data
After seeing the above error, I try to debug by running:
csv_file_write.writerow(['A','B','C'])
and I received the second error as below:
84 def writerow(self, row):
85 return self.writer.writerow(
---> 86 _stringify_list(row, self.encoding, self.encoding_errors))
87
88 def writerows(self, rows):
ValueError: I/O operation on closed file