A random coder
A random coder

Reputation: 473

pandas.read_csv() returning a ParserError

Today I turn my attention to the wonderful world of pandas. I am trying to read a .csv file, which is an easy task, but when I pass in the file (right here: https://raw.githubusercontent.com/grammakov/USA-cities-and-states/master/us_cities_states_counties.csv), it gives me this mess:

pandas.errors.ParserError: Error tokenizing data. C error: Expected 4 fields in line 9, saw 5

I have tried setting delimiter to an empty string, setting it to a variable, and declaring the type pd.Dataframe.

Upvotes: 1

Views: 1156

Answers (1)

wasif
wasif

Reputation: 15498

Use delimiter |, by adding either sep='|' or delimiter='|' to .read_csv() (both parameters mean the same thing). like

pd.read_csv(r'File_path', sep='|')

Upvotes: 3

Related Questions