frame/csv
src/frame/csv.tur
defn
read-csv-string
(read-csv-string [src :cstr delim :int quote :int has-header :int infer-rows :int null-str :cstr] :int)
parse a CSV blob from memory into a frame.
Parameters
| src | :cstr NUL-terminated CSV text | |
| delim | :int field separator codepoint (0 = ',') | |
| quote | :int quote character codepoint (0 = '"') | |
| has-header | :int 0 or 1 | |
| infer-rows | :int rows to scan for type inference (0 = 100) | |
| null-str | :cstr cell value treated as null (pass "" for default) |
Returns
:int frame handle, or 0 on parse failure / OOM. Free with frame-free.
Since: FR3
defn
read-csv
(read-csv [path :cstr delim :int quote :int has-header :int infer-rows :int null-str :cstr] :int)
defn
read-csv-typed
(read-csv-typed [src :cstr s :int delim :int quote :int has-header :int null-str :cstr] :int)
parse a CSV blob with an explicit schema (skips inference).
Since: FR3
defn
write-csv-string
(write-csv-string [f :int delim :int quote :int has-header :int] :cstr)
render the frame as a CSV cstr (caller frees with the
Parameters
| f | :int frame | |
| delim | :int separator (0 = ',') | |
| quote | :int quote char (0 = '"') | |
| has-header | :int 0 or 1 |
Returns
:cstr newly-allocated NUL-terminated buffer.
Since: FR3
defn
write-csv
(write-csv [f :int path :cstr delim :int quote :int has-header :int] :int)
render a frame as CSV and write to `path`.
Internal definitions
__c-nil__c-cons__csv-parse-string-- parse a NUL-terminated CSV blob into a __csv_table.__csv-table-rows-- number of data rows in a parsed table.__csv-table-cols-- number of columns in a parsed table.__csv-table-cell-- cell at (row, col); empty cells return "".__csv-table-header-- header for column c, or "col_N" if no header row.__csv-table-free-- release a parsed table.__csv-is-null?-- true for empty, null-str match, NA/NaN/NULL (case-insensitive).__csv-try-int64-- parse s as int64; returns 1 if successful, 0 otherwise.__csv-parse-int64__csv-try-float64__csv-parse-float64__csv-try-bool__csv-parse-bool__csv-try-date32-- match strict "YYYY-MM-DD" (10 chars, all digits/dashes).__csv-parse-date32-- "YYYY-MM-DD" -> days since 1970-01-01 (Howard__csv-try-timestamp-- match "YYYY-MM-DD HH:MM:SS" (19 chars) or with 'T'.__csv-parse-timestamp-- "YYYY-MM-DD HH:MM:SS" -> microseconds since epoch.__csv-infer-col-type-- infer the narrowest type for column c by scanning__csv-append-cell__csv-fill-builder__csv-storage-tag__csv-retag__csv-build-cols__csv-build-fields__csv-build-types__csv-build-types-from-schema__field-type-at__nth-int__slurp-- read CSV from a file path. Same options as read-csv-string.__cstr-free__cstr-null?__write-file