Pandas read_csv and UTF-16

前端 未结 3 560
隐瞒了意图╮
隐瞒了意图╮ 2020-12-19 00:06

I have a CSV text file encoded in UTF-16 (so as to preserve Unicode characters when others use Excel) but when doing a read_csv with Pandas 0.9.0, I get this cryptic error:<

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-19 00:52

    from StringIO import StringIO
    import pandas as pd
    
    a = ['Venezuela', 'N/A', 'President', '10/7/12', 'Hugo Rafael Chavez Frias', 'Hugo Ch\xc3\xa1vez', 'Hugo Ch\xc3\xa1vez', 'Hugo Chavez', 'Hugo Ch\xc3\xa1vez Fr\xc3\xadas', 'Hugo Chavez', 'Hugo Ch\xc3\xa1vez']
    
    pd.read_csv(StringIO('\t'.join(a)), delimiter='\t')
    

    works here can upload the head of your data so I can test

提交回复
热议问题