Python UTF-16 CSV reader

前端 未结 4 772
温柔的废话
温柔的废话 2020-11-27 21:49

I have a UTF-16 CSV file which I have to read. Python csv module does not seem to support UTF-16.

I am using python 2.7.2. CSV files I need to parse are huge size ru

4条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 22:28

    Just open your file with codecs.open like in

    import codecs, csv
    
    stream = codecs.open(, encoding="utf-16")
    reader = csv.reader(stream)
    

    And work through your program with unicode strings, as you should do anyway if you are processing text

提交回复
热议问题