小编Py1*_*y11的帖子

UnicodeError: UTF-16 stream does not start with BOM

I have trouble reading the csv file by python. My csv file has Korean and numbers.

Below is my python code.

import csv
import codecs
csvreader = csv.reader(codecs.open('1.csv', 'rU', 'utf-16'))
for row in csvreader:
    print(row)
Run Code Online (Sandbox Code Playgroud)

First, there was a UnicodeDecodeError when I enter "for row in csvreader" line in the above code.

So I used the code below then the problem seemed to be solved

csvreader = csv.reader(codecs.open('1.csv', 'rU', 'utf-16'))
Run Code Online (Sandbox Code Playgroud)

Then I ran into NULL byte error. Then I can't …

python csv error-handling

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

csv ×1

error-handling ×1

python ×1