by mangecoeur · 12y ago · 0 comments
Fact is, most of the world doesn't speak english and needs accents, symbols, or completely different alphabets or characters to represent their language. If POSIX has a problem with that then yes, it is wrong.
Even simple things like french or german accents can make the Py2 csv module explode, while Py3 works like a dream. And anyone who thinks they can just replace accented characters with ASCII equivalents needs to take some language lessons - the result is as borked and nonsensical as if, in some parallel univese, I had to replace every "e" with an "a" in order to load simple english text.
But that's not always the case with other libraries like the csv module. The core unicode support in py3 means that a lot of librares which are not written with explicit unicode in mind Just Work with it in py3, and its a huge time saver.
This works fine, as does the corresponding writer:
reader = csv.reader(open(FILENAME, 'rb'))
for row in reader:
print row
If you want a unicode string it's as simple as: value = row[0].decode('utf8')
Then before writing: row[0] = value.encode('utf8')