
Fixing Garbled Text in CSV Files and Keeping It Fixed
Why accents, euro signs and emoji break in CSV files, how to diagnose each symptom from the bytes, and one routine that converts, loads and checks a file.
Everything you need to level up your coding skills.

Why accents, euro signs and emoji break in CSV files, how to diagnose each symptom from the bytes, and one routine that converts, loads and checks a file.

An Excel date column holds serial numbers, real dates or text. Classify each value in the stage, convert each kind by an explicit rule and reject the rest.

Thirty six tiny CSV files that separate good readers from bad ones, with the right answer for each and the readers that missed it in my tests.

What mapping values are not allowed here means, three causes found in real files, an unquoted colon, a stray space and a double value, and the fix for each.

What Content is not allowed in prolog means in Java: a BOM decoded to text, a double BOM, JSON or text instead of XML, and how to diagnose it.

Find the real header row in an Excel sheet with a title, a date line or a logo above it, read from there with pandas, and cut notes and totals off the bottom.

TSV avoids most quoting because tabs rarely appear in text, but there are three TSV dialects and they disagree. See where each breaks and which to pick.

Every JSON parser reports a position in a different way. How to turn a character offset into a line, a column and a caret in Python, Node and jq.

Write CSV that survives every reader. Wrap fields with commas, quotes or line breaks, double inner quotes, and round trip test it against four readers.

Read every sheet of an Excel workbook with pandas, map each to its own staging table with safe names, skip hidden or unexpected sheets and verify the counts.

Fix undefined entity and Entity not defined errors in XML from HTML entities like nbsp and eacute: convert to numeric references, a DOCTYPE, or lxml recover.

A CSV stores text, so every reader infers types. Measure what inference costs in time and memory on 2 million rows, and what it breaks: ZIP codes and dates.
We send one email when a new article is published. No spam.