0

I have a long CSV file (150Mb+) which I am attempting to import, and when read_csv is used, pandas reports this error:

ParserError: Error tokenizing data. C error: Expected 26 fields in line 6100, saw 27

So I checked line 6100, and on the right you can see that one of the columns - which was completely empty up to this point - starts showing values,

enter image description here

My CSV file has 26 columns in the header, with the rightmost column corresponding to one of them, and I have tried different combinations of options, all the way up to

df = pd.read_csv(file_location, header=0, index_col=0, na_values = ["", 0]).fillna(value = 0),

to no avail.

Shouldn't Pandas treat empty cells as N/A's? Why would this cause such a problem?

halfer
  • 19,471
  • 17
  • 87
  • 173
Coolio2654
  • 1,459
  • 2
  • 16
  • 41

0 Answers0