DEV Community

Cover image for Parsing fixed-width exports and log lines safely
Georgi Kalchev
Georgi Kalchev

Posted on Originally published at aiskills402.com

Parsing fixed-width exports and log lines safely

Fixed-width files, CSV and log lines look easy to split and lose data quietly. Padding, implied decimals, quoting, log fields and syslog, from the specs.

Two kinds of text look trivial to convert and are not: an export where every field sits at a fixed position, and a log where every line follows a pattern. In both cases the conversion usually succeeds. A program reads the output without an error, and the damage is in the values: an identifier whose leading zeros vanished, a name that gained or lost spaces, a field cut one character early after a letter with a diacritic, a dash that turned into literal text, or a damaged line that someone patched into a record nobody wrote. This guide takes the two source formats and the two target formats in turn, using the specifications, and the final part is a test designed to go red.

Read the full report on AISkills402: https://aiskills402.com/blog/fixed-width-and-log-lines-parsing?utm_source=devto&utm_medium=social

Top comments (0)