python - unicodecsv doesn't read unicode csv file -
this line i'm trying read:
with open('u.item', 'w') demofile: demofile.write( "543|mis\xe9rables, les (1995)|01-jan-1995||" "http://us.imdb.com/m/title-exact?mis%e9rables%2c%20les%20%281995%29| "0|0|0|0|0|0|0|0|1|0|0|0|1|0|0|0|0|0|0\n" )
this way reading it
import unicodecsv csv def moviestordf(csvfilepath): open(csvfilepath, 'ru') csvfile: reader = csv.reader(csvfile, encoding='utf-8', delimiter= '|') row in reader: print row moviestordf("u.item")
this error getting:
unicodedecodeerror: 'utf8' codec can't decode byte 0xe9 in position 3: invalid continuation byte
the value throws error is:
misérables, les
what wrong did please?
(i using 2.7 python)
i found problem
the file encoded latin-1 not utf 8
this solves problem
reader = csv.reader(csvfile, encoding='latin-1', delimiter= '|')
Comments
Post a Comment