
Removing Blank Rows and Stray Footer Lines From a CSV
Report-style exports carry titles, blank lines, repeated headers and Total footers. Find the header, drop what is not data and check the footer's claims.
Take messy CSV, JSON and spreadsheets and land them in tables without losing a row or a character on the way.

Report-style exports carry titles, blank lines, repeated headers and Total footers. Find the header, drop what is not data and check the footer's claims.

Collapse USA, usa and United States with a mapping table, use casefold, and treat fuzzy matching as a suggestion: it ranked Australia above Austria.

Split names, emails and delimited cells into columns or rows in pandas, handle Last, First, and see why a row-by-row apply ran 40 times slower.

Normalize phone numbers to E.164 with a regex and the phonenumbers library; the regex accepted 43.8% more numbers than the library calls valid.

A CSV has no NULL, so missing arrives as empty, a dash, N/A or null. Inventory the tokens, convert to real NA, keep the reason and see what fillna(0) does.

Parse $1,234.50, (12.50), 1.234,50 € and 7,00 into exact Decimals, find the cases where stripping symbols is wrong, and spot a column that mixes currencies.

Four formats in one date column, 959 values that are not dates and 15,642 that could be read two ways. Parse with explicit formats and report what you cannot.

Deduplicating a CSV is easy; deciding which duplicate to keep is not. Compare first, last, latest-signup and highest-balance keepers on 200,000 rows.

Trim padded CSV fields with pandas, the csv module, DuckDB and qsv, and see why strip() misses the zero-width space that still breaks an email match.

A cleaning pipeline that never edits the raw file, counts rows at every step and keeps rejects: 200,000 rows in 3.85 s, identical output twice.

Why a CSV written by Python shows a blank line after every row on Windows, how newline='' prevents it, and how to check the bytes. Reproduced without Windows.

Fix _csv.Error field larger than field limit (131072). Tell a genuinely large cell from an unclosed quote, raise the limit safely and find the bad record.
We send one email when a new article is published. No spam.