Read and write CSV files (and other tabular delimited text formats) in Chez Scheme.
It intends to be more flexible, faster and robust than the delimited text procedures provided by chez-stats.
It can handle different CSV dialects (see make-dialect
below). By
default, it expects a dialect with #\,
as field delimiter, #\"
as
quotation character, Unix line termination style and non-significant
initial whitespace in every field.
$ akku install chez-csv
Copy chez-csv.sls
into your project's directory.
Once installed, import it into your Scheme file:
(import (chez-csv))
(csv-read input-port [dialect-record]) -> vector-of-#(vector-of-strings)
Dialect-record is optional. If provided, it must be a record constructed
with make-dialect
.
Returns the read CSV as a vector of vectors of strings, where every vector of strings corresponds to a row, and every string to a field.
(csv-write output-port vector-of-#(vector-of-strings) [dialect-record]) ->
{side effect}
Dialect-record is optional. If provided, it must be a record constructed
with make-dialect
.
Writes the provided vector of vectors of strings as a CSV in the specified dialect (when provided) or in the default one. Every vector of strings will be written as a CSV row, where every string is a field.
(make-dialect delimiter quotechar line-termination skip-initial-space)
-> dialect-record
unix
or dos
. Line-termination style.Returns a record representing the specified CSV dialect.