Reputation: 19
I was trying to read this text file using pandas.read_csv() but I get this error " ParserError: Error tokenizing data. C error: Expected 2 fields in line 30, saw 3". I know this is a silly question. I'm sort of a newbie. import pandas as pd data=pd.read_csv("source-document00001.txt",sep=".")
Upvotes: 0
Views: 6488
Reputation: 944
The previous answer is correct, but on the documentation it says, "Deprecated since version 1.3.0: The on_bad_lines parameter should be used instead to specify behavior upon encountering a bad line instead."
data = pd.read_csv('source-document00001.txt',sep='.',on_bad_lines='skip')
Upvotes: 0
Reputation: 1749
You can skip the erroring rows
data = pd.read_csv("source-document00001.txt",sep=".", error_bad_lines=False)
Upvotes: 2