
Header Variants and Normalizing Column Names in CSV Files
Clean up messy CSV headers into stable column names: BOMs, spaces, case, accents, duplicates, blanks and leading digits, with a function you can test.
Everything you need to level up your coding skills.

Clean up messy CSV headers into stable column names: BOMs, spaces, case, accents, duplicates, blanks and leading digits, with a function you can test.

Turn a CSV with a title row and a two level header into a flat table: skip the title, forward fill merged top cells and join the levels into column names.

Read pipe delimited files from banks and mainframes: a trailing pipe that adds a phantom column, unquoted values containing pipes, trailers and code pages.

Convert a fixed width file to CSV by slicing each line at known positions, check every line length, and handle implied decimals, padding and wide characters.

PostgreSQL COPY has a CSV format and a text format that differ in delimiter, NULL marker and escaping. See the same rows in both and what a mismatch loads.

Where Excel's CSV departs from RFC 4180: delimiter, encoding, BOM, the sep line, displayed values, formulas and the ID trap, plus a converter script.

Describe a CSV's delimiter, header, column names, types and keys in a CSVW metadata file, then use it to read the file correctly. Includes a working example.

The CSV dialects that exist in the wild, from RFC 4180 and Excel to PostgreSQL text, MySQL, TSV and pipes, with the settings that tell them apart.

Generate a Markdown table from a YAML list in Python, escaping pipes, joining lists, handling blanks and keeping the table in sync with the YAML in CI.

Read a key, value and type sheet with openpyxl, build nested YAML from dotted keys, and keep versions, dates and blanks from changing on the way.

Convert YAML to XML with xmltodict, using @ keys for attributes, repeated elements for lists, and checks for invalid names and the single-root rule.

Turn CSV rows into a YAML list of mappings in Python, keeping zip codes as text and giving integers, floats, booleans and empty cells the right types.
We send one email when a new article is published. No spam.