Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)
edited by

I'm trying to use pandas to manipulate a .csv file but I get this error:

pandas.parser.CParserError: Error tokenizing data. C error: Expected 2 fields in line 3, saw 12

I have tried to read the pandas docs, but found nothing.

My code is simple:

path = 'GOOG Key Ratios.csv'

#print(open(path).read())

data = pd.read_csv(path)

How can I resolve this? Should I use the csv module or another language ?

File is from Morningstar

1 Answer

0 votes
by (41.4k points)

This below line of code will cause the offending lines to be skipped.

data = pd.read_csv('file1.csv', error_bad_lines=False)

Browse Categories

...