std/csv
Strict CSV rows, following RFC 4180 and Go encoding/csv. CRLF is normalized to LF, including inside quoted fields. Blank lines are skipped; spaces are data. Errors use one-based scalar line/column. Streams consume chunks only on demand, retain at most one row plus the current chunk, and end after the first error. Pulls are replayable.
Options
Options = (delimiter = Int, fields = Int, crlf = Bool) CsvError
CsvError = (line = Int, column = Int, reason = String) options
A single scalar delimiter, expected width (0 infer, negative variable),
and output line ending. Quotes, NUL, CR, LF, U+FFFD are invalid delimiters.
csv.options(";", -1, True).
options = (delimiter : String, fields : Int, crlf : Bool) -> Result( defaults
Comma delimiter, infer row width, LF output.
defaults = () -> Options { Options(delimiter = 44, fields = 0, crlf = False) } parse
Parses comma-separated text, inferring the width from the first row.
csv.parse("a,b\n1,2\n") gives Ok([["a", "b"], ["1", "2"]]).
parse = (input : String) -> Result(List(List(String)), CsvError) { parse_with
Parses with an explicit delimiter and row-width policy.
parse_with = (input : String, config : Options) -> Result( parse_header
Header-mode convenience parser: csv.parse_header("name\ni\n", csv.defaults()).
parse_header = (input : String, config : Options) -> Result( Prints minimal quoting, with one LF after every row.
csv.print([["a", "b,c"]]) gives "a,\"b,c\"\n".
print = (rows : List(List(String))) -> String { print_with(rows, defaults()) } print_with
Prints with the configured delimiter and LF/CRLF. Empty rows print as "".
print_with = (rows : List(List(String)), config : Options) -> String { rows
Parses a stream of arbitrary text chunks, emitting one row per pull.
csv.rows(stream.from_list(["a,", "b\n"]), csv.defaults()).
rows = <E, N>( records
Uses the first row as unique column names. Empty input yields no records.
records = <E, N>( decode
Decodes a named row as a JSON object of strings using an ordinary schema.
Compose schema.string with schema.map for domain conversions.
decode = <A, E>(