Fix the ParserError in Python: Error tokenizing data. C error: Expected N fields in line (2 Examples)
On this page you’ll learn how to deal with the “ParserError: Error tokenizing data. C error: Expected X fields in line Y, saw Z” in the Python programming language.
Example 1: Replicating the ParserError: Error tokenizing data. C error: Expected N fields in line
my_df = pd.read_csv('my_df.csv') # Reading CSV file does not work # ParserError: Error tokenizing data. C error: Expected 4 fields in line 5, saw 5 |
my_df = pd.read_csv('my_df.csv') # Reading CSV file does not work # ParserError: Error tokenizing data. C error: Expected 4 fields in line 5, saw 5
Example 2: Fixing the ParserError: Error tokenizing data. C error: Expected N fields in line
my_df = pd.read_csv('my_df.csv', error_bad_lines = False) # Remove rows with errors |
my_df = pd.read_csv('my_df.csv', error_bad_lines = False) # Remove rows with errors