CSV Export Turns 1.5 into Two Columns? Check the Locale Contract
- PLC Play Ground
- 0
- Posted on
A CSV file can be structurally valid yet import incorrectly when producer and consumer disagree about delimiters or decimal notation. Define both explicitly.
Original interchange example; validate the actual producer and consumer.
What is happening?
CSV dialect governs separators and quoting; numeric interpretation adds another layer. A comma may be a field separator or part of a locale-formatted number. Spreadsheet auto-detection can conceal the disagreement until values are reused.
Check these five things
-
Inspect the raw exported text in a plain-text viewer.
-
Record delimiter, quoting, encoding, and decimal convention.
-
Check the receiving application import settings.
-
Include representative decimals and text containing separators.
-
Validate values after import rather than only the appearance.
Worked example
A teaching export intends two fields: Pump A and numeric 1.5. A locale-formatted 1,5 written without appropriate quoting into a comma-delimited file can be interpreted as extra fields. A documented dialect and numeric convention avoid the ambiguity.
Quick diagnostic reference
| Contract item | Example decision |
|---|---|
| Delimiter | Comma or semicolon |
| Decimal | Point or locale rule |
| Quoting | Escape embedded delimiters |
The mistake to avoid
Do not fix a file by globally replacing commas. That can corrupt delimiters, quoted text, and legitimate data.
How to verify the fix
Round-trip a small reference dataset containing decimals, negative values, empty fields, and quoted text. Compare parsed values exactly.
Field-work boundary: These are educational diagnostic guides. Use the exact equipment manuals and approved site procedures. Electrical testing and machinery changes belong to qualified, authorized personnel; control hazardous energy and validate affected functions before release.
Technical reference
Python documentation: CSV dialects and parsing. The examples and diagnostic tables above are original teaching material; they do not replace the product manual.
