The most expensive CSV import error can be invisible: the import succeeds, the row count matches, and the identifier that ties an invoice to its product has silently changed.
One hundred identifiers, twenty-five lost identities
We generated 50 eight-character zero-padded IDs and 50 distinct integer strings above JavaScript's safe-integer range. Converting every value with Number and back to a string changes 75 of the 100 values. The distinct-key count drops from 100 to 75.
| Representation | Distinct keys |
|---|---|
| Original text | 100 |
| JavaScript Number coercion | 75 |
Leading-zero loss changes identity even if it does not create a collision. Above the safe integer limit, neighboring IDs can collapse to the same number. This experiment used JavaScript, not an Excel execution. Separately, Microsoft documents Excel's 15-digit precision limit; importing numbers as text must be explicit there too.
A CSV record may occupy multiple physical lines
RFC 4180 (CSV specification) permits quoted fields containing line breaks and commas. The fixture below represents one data record over two physical lines. Splitting by newline destroys its logical structure.
import { csvToRecords } from "@codedeb/data-bridge";
const csv = 'id,description\r\n00001234,"Line 1\nLine 2"';
const rows = csvToRecords(csv);
// Keep rows[0].id as a string, not Number(rows[0].id).
Headers must be unique, required columns must be present and missing versus empty values should be distinguishable. Use an approved mapping for fields rather than directly treating arbitrary header text as object paths. Data Bridge documentation describes the supported parser and mapping contracts.
The spreadsheet export and machine export must differ
The machine-oriented file should preserve exact values. An operator-facing spreadsheet export must also account for formula interpretation. OWASP CSV injection guidance explains the risk of formulas embedded in user-controlled values. Escaping CSV syntax is not equivalent to preventing spreadsheet execution. Test the destination application and avoid modifying the original stored business value as a side effect of creating a safer display file.
Reconciliation should compare identities, not only counts
Stage records before writing to inventory. Build a map of source IDs, identify duplicates, validate foreign keys and report rejected records by logical row. If a file has 100 rows but only 75 distinct normalized IDs, an upsert can silently overwrite records. A second import of the same accepted file should return the existing import outcome. Compare inserted, updated, rejected and duplicate counts plus the source and destination key sets.
Deciding what can be automated safely
Normalize only fields whose contract requires it. For a phone number, deliberate digit conversion is useful; for a product reference, preserving its exact characters may be mandatory. Nepal form normalization and identifier design show the difference. Use JSON, CSV and Excel converter for conversion and a separate reviewed migration workflow for financial or inventory records. The experiment is a reason to add collision assertions, not a claim that any particular file has been damaged.
Method and reproducibility: Controlled synthetic model. See Code Deb's recorded experiment results and reproduction script in the repository. Figures are reproducible from declared inputs, not undisclosed client outcomes. The cited external material is independent of Code Deb's experiment.