3

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: ordinal 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.

1 Answer 1

7

Try the unicode_csv_reader() generator described in the csv module docs.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.