CSV and TSV Conformance
Lanexio™ Parser implements RFC 4180 compliant CSV and TSV parsing with configurable delimiters, field quoting, and header-row detection. A single package (@lanexio/parser-grammar-csv) exports both parseCsv and parseTsv.
RFC 4180 compliance
Section titled “RFC 4180 compliance”The conformance suite validates every clause of the RFC:
- §2.1 — Basic format: header row, record separation, field counts
- §2.3 — Header row:
CSV_FLAG_HEADERdetection and opt-in control - §2.4 — Multiple records: optional trailing newline
- §2.5 — Whitespace: significant whitespace within quoted fields, insignificant elsewhere
- §2.6 — Quoted fields: double-quote escaping, embedded commas, embedded line breaks
- §2.7 — Double-quote within quoted field
610 tests pass across the CSV and TSV grammar paths.
Strict mode
Section titled “Strict mode”Both parseCsv and parseTsv accept a mode option ("lenient" or "strict"). The default is "lenient", which keeps the recovery behavior of every previous release.
In "strict" mode the parse path still never throws, but spec-level rejections are surfaced as flags:
- A record that fails to parse (an unclosed quote, or a bad quote position) is flagged on its
Recordnode. - A record whose field count differs from the reference row is also flagged. The reference is the header row when
header: true(the default), otherwise the first record. - When any record is rejected, the
Documentroot carriesLEX_NODE_HAS_ERROR | GRAMMAR_FLAG_NODE_ERRORandtree.root.hasErrorreadstrue.
Use strict mode when a downstream consumer needs a single, callable guarantee that the input is a rectangular table. Keep "lenient" when you parse heterogeneous or streaming data and only care about recovery.
Four-axis bar
Section titled “Four-axis bar”| Axis | Result |
|---|---|
| never-throw | 0 throws across full corpus |
| well-formed | corpus WF = 0 |
| lossless | corpus lossless = 0, byte-exact round-trip |
| conformance | 610/610, RFC 4180 covered |
Corpus conformance
Section titled “Corpus conformance”pnpm conformance:suite measured this family over the test_files/csv corpus on 2026-10-06 at
Lanexio™ Parser version 1.0.0:
| family | valid | invalid | raw | contract-subset | REAL-DEFECT |
|---|---|---|---|---|---|
| csv | 552 | 3 | 99.1% | 99.6% (550/552) | 2 |
The contract-subset here is the clean valid inputs over all valid inputs (this family carries no artifact buckets); the 2 REAL-DEFECT entries are valid-classified files that report an error.