tupelo.csv
Utils for reading CSV (comma-separated-value) formatted files.
attrs->entities
(attrs->entities cols-map)
Inputs: [cols-map :- tsk/Map]
Returns: [tsk/Map]
Converts a map of attribute-vectors into a vector of entity-maps. Not lazy.
entities->attrs
(entities->attrs row-maps)
Inputs: [row-maps :- [tsk/Map]]
Returns: tsk/Map
Converts a sequence of entity-maps into a map of column-vectors. Not lazy.
parse->attrs
(parse->attrs csv-input & {:as opts})
[csv-input & {:as opts} ]
Returns a map of attributes constructed from the columns of csv-input. The first line is
assumed to be column label strings, which are (safely) converted into keywords. The
returned map has one entry for each column label keyword. The corresponding value for
each keyword is a vector of string data taken from each subsequent line in the file.
See tupelo.csv/parse->entities for options. Not lazy.
parse->entities
(parse->entities csv-input & opts)
Inputs: [csv-input & opts]
Returns: [tsk/Map]
[csv-input & {:as opts} ]
Returns a lazy sequence of maps constructed from csv-input. The first line
is assumed to be column label strings, which are (safely) converted into keywords.
String data from each subsequent line is paired with the corresponding column keyword to
construct a map for that line. Default delimiter is the comma character (i.e. \,) but
may be changed using the syntax such as:
```
(parse-csv->row-maps <csv-data-src> :delimiter \|)
```
to select the pipe character (i.e. \|) as the delimiter.
<csv-data-source> is either a multi-line-string, or a java.io.Reader.