
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.
Tag
590 posts

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.

Where each parser sets its alias limit: SnakeYAML options, Go's built-in check, Ruby's aliases flag, DuckDB's node budget and a PyYAML guard, all tested.

Turn an Excel sheet of settings or tables into YAML in Python: shape the data, avoid the Norway problem and number traps, dump safely and validate.

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

Convert an Excel sheet to XML in Python: valid element names, escaping, elements versus attributes, encoding, large files and validation against a schema.

Pretty print JSON with json.dumps(indent), python -m json.tool and pprint, keep non-ASCII readable, sort keys and collapse short arrays.

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.

Convert an Excel sheet to JSON in Python: records, nested groups and JSON Lines, with typed values, ISO dates, nulls and a check that nothing was lost.

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 40-line guard for accepting YAML uploads: size cap, UTF-8, safe parsing, expanded-size and depth limits, then key checks. Ten test inputs and what each did.

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.

Check an Excel upload before parsing: size, name, zip signature, required parts, macro parts, sheet names and header row, in a fixed order with clear errors.