熊猫:UnicodeDecodeError:'utf-8'编解码器无法解码位置0-1处的字节:无效的连续字节

问题描述 投票:0回答:1

社区。我想使用熊猫打开CSV并对其进行分析。请帮忙,因为我无法打开CSV本身。我尝试使用UTF-8,Latin-1和ISO-8859-1编码打开它。没用代码:

csv_file3='COVID-19-geographic-disbtribution-worldwide.csv'
with open(csv_file3,'rt')as f:
    data = csv.reader(f)
    j=0
    for row in data:
         j+=1

错误:

Traceback (most recent call last):
  File "analysisofcases.py", line 87, in <module>
    for row in data:
  File "/usr/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 15-16: invalid continuation byte

This is the CSV that I want to open. This is my code and the error when I ran the code.** Please check and see what the problem is**

pandas csv unicode utf-8 codec
1个回答
0
投票

尝试一下,也选中此standard encodings

data = pd.read_csv("COVID-19-geographic-disbtribution-worldwide.csv", encoding = 'unicode_escape', engine ='python')
© www.soinside.com 2019 - 2024. All rights reserved.