vellum-csv
November 17, 2021 ยท View on GitHub
This system adds a basic support for reading tables from and writing tables to csv files.
#+BEGIN_SRC common-lisp (defparameter table (vellum:copy-from :csv "/path/to/csv/file/csv.csv" :includes-header-p t :columns '(a b))) #+END_SRC
This system also supports cl-ds.fs:command input which allows to handle csv output produced by other programs. This is handy when dealing with compressed csv files.
#+BEGIN_SRC common-lisp (vellum:copy-to :csv "~/output.csv" table ) #+END_SRC
Strings are automaticly converted to values, depending on the :TYPE of the column. Only numbers and strings are supported at this point though. Additional types can be supported by specializing FROM-STRING and TO-STRING generic functions.
This system is implemented by the means of the CSV-RANGE. CSV-RANGE can be used on it's own to aggregate CSV files that are unsuitable for putting in to the table. Example of these are a very large files, that are unlikely to fit into the main memory. Using reservoir sampling or data sketch techniques (available in CL-DS) can be favored in those situations.
Parser implemented in this system is based on the code written by Gilbert Baumann. Writer is based on the fare-csv code.