Issue #2745: An official csv package reads a CSV text into declared rows and writes them back, taken in by use csv (ADR-338)

Open and answer this issue on GitHub.

blocked, csv · opened 2026-11-22 · updated 2026-11-22 · 0 comments

Part of #539

Goal. An official package csv that reads a CSV text into declared rows and writes rows back into CSV text, taken in by use csv with no manifest entry, as json is.

Governing decision. ADR-338 D2 (official package), D3 (taken in by its first use), D5 (csv reads and writes; editing an existing text with its comments and order is not part of it). The row type follows the rules of dsl … -> T: a row is a declared struct, its fields matched by name, strictly (ADR-299 D15-D19), as built by #477.

Where it stands (read in the repository). No csv package exists (git ls-files | grep -i csv finds only test inputs: examples/report/tests/*/stock.csv, examples/inventory/tests/four-items.in/stock.csv). examples/report/src/main.nika reads stock.csv by hand (split(";")). The list of official packages is project_members_official() in crates/nikaia-std/src/compiler/project_members.nika (db, json).

Needs #477

Done when. A project with use csv and no [dependencies] entry reads a CSV text with quoted fields and doubled quotes ("a ""b""") into a Vec[Row] of a declared struct, writes it back to the same text, and a missing or extra column is refused with the line and column named. The last code step carries Fixes #N; the report gives a Found: line per finding.

To build

  1. packages/csv with a pub grammar Csv (RFC 4180: separator, quoted fields, "" inside quotes, CRLF and LF), reading into rows of text; tests in packages/csv/tests/.
  2. Typed reading csv::read[T](text) into Vec[T] by header name, by the row rules of #477; a failed row names its line and the column (as json names at $.path). Test: a missing column, an extra column, a field that does not parse as the field’s type.
  3. csv::write[T](rows): the header from the field names, quoting where a field holds the separator, a quote or a line break. Test: read then write gives the same text.
  4. csv joins project_members_official(); test in tests/compiler/tests/: use csv with no manifest entry builds offline.
  5. examples/report reads stock.csv through csv::read[T] instead of splitting by hand; its outputs unchanged.

Files and limits. New packages/csv/, compiler/project_members.nika (one list entry), examples/report/src/main.nika. Not: packages/json, packages/yaml.

Open for the builder. The separator: ; as examples/report uses, or , with a parameter. The builder chooses and names it in the report.

Back to Open Issues