8

community. I want to open a CSV using pandas and perform analysis on it. Please, help as I am not able to open the CSV itself. I tried opening it with UTF-8, Latin-1, and ISO-8859-1 encoding. It didn't work. CODE:

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

ERROR:

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**

Sezal Chug
  • 81
  • 1
  • 1
  • 3

1 Answers1

34

Try this,check this standard encodings as well.

data = pd.read_csv("COVID-19-geographic-disbtribution-worldwide.csv", encoding = 'unicode_escape', engine ='python')
Rajith Thennakoon
  • 3,975
  • 2
  • 14
  • 24