i trying read csv file cp1252 encoding this:
import io import csv csvr = csv.reader(io.open('data.csv', encoding='cp1252')) row in csvr: print row
the relevant content of 'data.csv' is
curva iv fecha: 27-jul-2016 16:22:40 muestra: 1 tensiĆ³n corriente ig 0.000000e+000 1.154330e-004 -2.984730e-004 ...
and following output
['curva iv'] ['fecha: 27-jul-2016 16:22:40'] ['muestra: 1'] traceback (most recent call last): file "d:/sandbox/bla.py", line 347, in <module> mist() file "d:/sandbox/bla.py", line 343, in mist row in csvr: unicodeencodeerror: 'ascii' codec can't encode character u'\xf3' in position 5: ordinal not in range(128)
which not understand @ all. critical line accent on 'o'. seems iterator of object returned csv.reader attempting conversion. exception raised before print statement, not problem terminal encoding. ideas going on here?
from docs:
note
this version of csv module doesn’t support unicode input. also, there issues regarding ascii nul characters. accordingly, input should utf-8 or printable ascii safe; see examples in section examples.
the input has converted utf-8 before passing csv.reader.
Comments
Post a Comment