[Tutor] UnicodeDecodeError

thehouse.be at me.com thehouse.be at me.com
Sun Mar 15 11:41:23 EDT 2020


I am a beginner, learning Python.
So sorry if my question is basic.

I am trying to work with .csv files in order to analyse data which comes from a Google Forms survey.
Idea is to handle the raw data, do some statistical analysis and make a report.

When trying to convert the data into a listy of lists, I get a UnicodeDecodeError.

This is what I do:

>>> import csv
>>> exampleFile = open(‘example.csv’)
>>> exampleReader = csv.reader(exampleFile)
>>> exampleData = list(exampleReader)

This last statement generates:
—————————————————————————————————————
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-9-3817c0931c6f> in <module>
----> 1 exampleData = list(exampleReader)
/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6/encodings/ascii.pyc in decode(self, input, final)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1798: ordinal not in range(128)

I suppose there is a bizarre character somewhere in the file, but no idea where.
As we use accents and umlauts in our language, could that be the problem?
If that would be the problem, how to solve?

Best regards and tnaks for the help,
Chris



More information about the Tutor mailing list