Csv
Csv module: streaming CSV parser.
Two consumption modes: each_row(path, delimiter, mode, callback) -- streaming; guaranteed cleanup read_all(path, delimiter, mode) -- eager; for small files
Modes: :simple -- split on delimiter only; no quoting :rfc4180 -- full RFC 4180: quoted fields, "" escapes, embedded newlines (including embedded CR / LF / CRLF inside quoted fields)
Line-terminator handling The parser accepts CRLF (RFC 4180), LF (Unix), and bare CR (legacy Mac) as record separators interchangeably. The output strings have trailing CR and LF stripped. Inside :rfc4180 quoted fields, raw CR and LF bytes are passed through verbatim — only the closing " ends the field.
Convenience: read_csv(path) -- comma-delimited, :rfc4180, eager each_csv_row(path, callback) -- comma-delimited, :rfc4180, streaming
Types
Functions
Convenience: comma-delimited, RFC 4180, streaming. Equivalent to each_row(path, ",", :rfc4180, callback).
Stream rows from path one at a time, invoking callback(fields) for each row. delimiter is a one-character String (",", "\\t", …); mode is :simple (split-only, no quoting) or :rfc4180 (full RFC 4180 with quoted fields, "" escapes, embedded newlines).
The file handle is closed when iteration reaches EOF or when the
callback panics. Returns `Ok(:ok)` on success, `Err(file_error)`
if the file cannot be opened.Stream rows treating the first row as a header. Invokes callback(header, fields) for every subsequent row, where header is the parsed first row. An empty file yields Ok(:ok) without invoking the callback. Closes the file on EOF or on callback panic.
Eagerly read every row of path into a List(List(String)). Returns Ok(rows) or Err(file_error). Use each_row/4 for files that don't comfortably fit in memory.
Convenience: comma-delimited, RFC 4180, eager. Equivalent to read_all(path, ",", :rfc4180).