Python 3: Csv Files And Unicode Error
I have a csv (tsv) file with this header 'Message Name' 'Field' 'Base Label' 'Base Label Update Date' 'Translated Label' 'Translated Label Update Date' 'Language' 'Message
Solution 1:
Your data is not encoded in 'utf-8' but in 'utf-16-le' or something similar. 'utf-16-le' is just a guess. When I encode your data with 'utf-16-le' exactly the same errors are produced. Check the encoding of your data file. In Linux you can use an editor like emacs for that or the 'file' utility.
The error message itself tells us that the first byte of your file is 0xff. This is, potentially, part of the Byte-Order Mark.
Solution 2:
If you just make one change in the code line than it might get work
withopen(fileName, 'r', encoding='utf-16') as fdata:
Solution 3:
For some reason, python does not like a single backslash. Try it again but replace all of your single backslashes with two. Goodluck.
Post a Comment for "Python 3: Csv Files And Unicode Error"