veko doc
Self-Contained API Reference • Gradual Types • Capabilities • Wasm Sandbox

codec/csv

lib/codec/csv.vk

lib/codec/csv.vk Pure-Veko RFC 4180 CSV parser, header-mapped record decoder, and serializer. Zero capabilities required.

signature
parse = fn [input str] block[block[str]]

Parses RFC 4180 CSV text into rows of string fields (block[block[str]]). Supports quoted fields, embedded commas/newlines, and "" escaped quotes.

Executable Example
veko
use [csv = codec/csv]
rows = csv/parse 'name,note\nalpha,"hello, ""world"""\nbeta,plain'
if (len rows) != 3 or rows[1][1] != 'hello, "world"' [ err 'csv/parse' ] else [ .ok ]
signature
parse-records = fn [input str] block[map[str]]

Parses CSV text whose first row contains column headers into block[map[str]].

Executable Example
veko
use [csv = codec/csv]
recs = csv/parse-records 'host,port\napi.local,8443\ndb.local,5432'
if (len recs) != 2 or (map/get recs[0] 'port') != '8443' [ err 'csv records' ] else [ .ok ]
signature
encode = fn [rows block[block[str]]] str

Encodes rows (block[block[str]]) into RFC 4180 CSV text separated by \n.