python - Writing unicode data in csv -
i know similar kind of question has been asked many times have not been able implement csv writer writes in csv (it shows garbage).
i trying use unicodewriter mention in official docs .
ff = open('a.csv', 'w') writer = unicodewriter(ff) st = unicode('displaygrößen', 'utf-8') #gives (u'displaygr\xf6\xdfen', 'utf-8') writer.writerow([st])
this not give me decoding or encoding error. writes word displaygrößen
displaygrößen
not good. can 1 me doing wrong here??
you writing file in utf-8 format, don't indicate csv file.
you should write utf-8 header @ beginning of file. add this:
ff = open('a.csv', 'w') ff.write(codecs.bom_utf8)
and csv file should open correctly after program trying read it.
Comments
Post a Comment