Recipe for using unicode files (i.e. files opened with codecs.open
) with the csv module.
1 2 3 4 5 6 | import codecs
import csv
def csv_unireader(f, encoding="utf-8"):
for row in csv.reader(codecs.iterencode(codecs.iterdecode(f, encoding), "utf-8")):
yield [e.decode("utf-8") for e in row]
|
Yes, the CSV module really is that dumb.