Pcornel
Automation · Data Formats

CSV

Cheat sheet · https://pcornel.dk/topic.php?topic=5835

Back to the Topic

Answer

CSV (comma-separated values) stores tabular data as text rows, easy to export from spreadsheets and import into scripts with Import-Csv or Python's csv module, but with no data types or nesting.

Remember

  • No data types or nesting.
  • Delimiters vary.
  • Use a real parser.

First checks

  • head -3 file.csv — header and sample
  • csvlint / python csv check — validity
  • file file.csv — encoding

Verify in this order

CSV → parser → rows → validation

Where it usually breaks

Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.

Data Formats → CSV · operational reference

LayerData Formats → CSV operational reference
Runtime/ownershipCSV interchange and automation parsers · the CSV producer/parser pair interpreting records, fields, quoting and line boundaries
Persistent intentdocumented dialect contract: delimiter, quote character, header presence, encoding, newline policy and null/empty conventions
VerificationParse a fixture containing commas, quotes, CRLF/newlines and empty fields with the production parser settings; serialize it again and compare field values and column count.
Expected interpretationEach logical record and field round-trips without delimiter/quote corruption, headers map deterministically, and malformed rows are rejected or surfaced rather than silently shifted.
Recovery boundarypreserve the original bytes and parser settings, correct the dialect/schema mismatch instead of hand-editing rows, then reparse the same fixture and compare typed records

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5835

Confirmation

Confirm action

Continue?