UnicodeDecodeError reading string in CSV
I'm having a problem reading some chars in python.
I have a csv file in UTF-8 format, and I'm reading, but when script read:
Preußen Münster-Kaiserslautern II
I get this error:
Traceback (most recent call last): File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/__init__.py", line 515, in __call__ handler.get(*groups) File "/Users/fermin/project/gae/cuotastats/controllers/controllers.py", line 50, in get f.name = unicode( row[1]) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 4: ordin开发者_开发技巧al not in range(128)
I tried to use Unicode functions and convert string to Unicode, but I haven't found the solution. I tried to use sys.setdefaultencoding('utf8')
but that doesn't work either.
Try the unicode_csv_reader()
generator described in the csv module docs.
精彩评论