ParserError: Error tokenizing data. C error: Calling read(nbytes) on source failed. Try engine='python'.: how to fix it (pandas)
Fix CSV parsing issues fast: locate broken rows and validate locally (no upload).
What the error means
ParserError: Error tokenizing data. C error: Calling read(nbytes) on source failed. Try engine='python'. usually means the CSV parser lost track of rows/columns because of delimiter or quoting problems. The fix is almost always: find the first broken row and fix it.
Most common causes
- Wrong delimiter (comma vs semicolon vs tab) so columns shift.
- Broken quoting: missing closing quote or quotes inside fields not escaped.
- Newlines inside quoted fields (multi-line cells) handled incorrectly.
- Header has N columns but a row has a different number of fields.
- Encoding issues or stray control characters in the file.
How to find the broken row fast
- Validate the file with CSV Validator to find rows with the wrong number of columns.
- Check for unmatched quotes and newlines inside quoted fields.
- Verify the delimiter (comma/semicolon/tab). A wrong delimiter often looks like columns shifted.
Once the first broken row is fixed, most parser errors disappear.
Fix checklist
- Validate the CSV structure first (delimiter + quotes + column counts).
- Locate the first broken row (usually where parsing stops). Fix that row before touching others.
- Re-validate and only then convert/export.
Code example (python)
# pandas read_csv checklist
import pandas as pd
# If the error is about field counts, try delimiter explicitly
# df = pd.read_csv('file.csv', sep=';')
# If the error is about quotes/newlines, locate the first broken row and fix it first
# (CSV Validator can help pinpoint the row)
df = pd.read_csv('file.csv')
Validate locally (no upload)
If your CSV contains sensitive data, use local-only tools:
- CSV Validator to detect delimiter/quote issues and mismatched rows.
- CSV to JSON after the structure is valid.
Workflow: validate -> fix the first failing row -> validate again -> convert.
FAQ
Why do numbers in the error message differ from my file? Some parsers count from 0, others from 1, and some count physical lines (including wrapped multi-line cells). Use a validator to pinpoint the first broken row.
Can I auto-fix broken CSV? Sometimes, but it is risky. Fixing the delimiter and unmatched quotes is usually the safest approach.