I'm learning python3 and I ended up packing on the issue of reading a simple csv file that contains the character 'à'. I've tried using decode, encode that I found on the internet but nothing seems to work, it is always printed as '\ xc3 \ xa0'. Remembering that I use the sublime to edit the code and run it.
import csv
with open('teste.csv', 'r') as ficheiro:
reader = csv.reader(ficheiro, delimiter=';')
for row in reader:
print(row)
The test.csv file:
batata;14;True
pàtato;19;False
papa;10;False
The error:
Traceback (most recent call last):
File "/Users/Mine/Desktop/testando csv.py", line 5, in <module>
for row in reader:
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 16: ordinal not in range(128)
[Finished in 0.1s with exit code 1]
I look forward to helping you.