A table is vector of vectors where the first row represents the header and the rest represent the rows
A table is vector of vectors where the first row represents the header and the rest represent the rows
(-extract-opts tokens)Extracts the opts from the tokens and returns [opts tokens]
Extracts the opts from the tokens and returns [opts tokens]
(-token-or-resolve env token)(col-headers interpretation)(data interpretation)(interpret table)(interpret opts table)Interprets the tabular data into a map with :col-headers, :row-headers, :data and :transformations.
:col-headers - a seq of column headers :row-headers - a seq of row headers :data - a vector of vectors with row values :transformations - a map with specificed tranformations to be done.
The interpretation can be configured using :
;;;;In order to interpret the table dsl, options can be ;;;;provided with a :separator and :divider. :seperator is the token ;;;;between columns and :divider is the column value in the divider ;;;;row. Default interpretation-opts are: ;;;;`{:separator '| :divider #"-{2,}"}
Interprets the tabular data into a map with :col-headers, :row-headers, :data
and :transformations.
:col-headers - a seq of column headers
:row-headers - a seq of row headers
:data - a vector of vectors with row values
:transformations - a map with specificed tranformations to be done.
The interpretation can be configured using
:
;;;;In order to interpret the table dsl, options can be
;;;;provided with a :separator and :divider. :seperator is the token
;;;;between columns and :divider is the column value in the divider
;;;;row. Default interpretation-opts are:
;;;;`{:separator '| :divider #"-{2,}"}
(row-headers interpretation)(tabularize tokens)(tabularize opts tokens)Interprets tokens into a 'table', a vector of vectors, using either the option :width to determine the number of columns per row, or if :width is not present, figures out the width using :divider to find a divider row.
In order to interpret the table dsl, opts can be provided with a :separator and :divider. :separator is the token between columns and :divider is the column value in the divider row.
Default opts are: {:separator '| :divider #"-{3,}"}
Takes as arguments either a seq of tokens and an opts map, or a map
with :tokens and :opts (which is the output of tokenize).
Interprets tokens into a 'table', a vector of vectors, using either the option
:width to determine the number of columns per row, or if :width is not present,
figures out the width using :divider to find a divider row.
In order to interpret the table dsl, opts can be provided with a :separator
and :divider. :separator is the token between columns and :divider is the
column value in the divider row.
Default opts are: `{:separator '| :divider #"-{3,}"}`
Takes as arguments either a seq of tokens and an opts map, or a map
with :tokens and :opts (which is the output of `tokenize`).(tokenize opts & elements)Tokenizes the elements sent in. If the first or last element is a map, that map is considered being a map of options.
tokenize itself is only interested in one option: resolve. If the resolve
option is true, any symbol is trying to be resolved. If the symbol can't
be resolved, it stays a symbol. This is necessary since the dividers in the
table are built up with symbols.
The function returns a map with :tokens, containing all tokens (with resolved or unresolved symbols) and :opts for all options in the options map, except :resolve (since that is consumed by tokenize).
The reason for having tokenize resolving instead of (for instance) interpret
is that tokenize is a macro, which means that is is in the right context to
resolve whatever the user code is refering to, while a normal function is not.
Tokenizes the elements sent in. If the first or last element is a map, that map is considered being a map of options. `tokenize` itself is only interested in one option: resolve. If the resolve option is true, any symbol is trying to be resolved. If the symbol can't be resolved, it stays a symbol. This is necessary since the dividers in the table are built up with symbols. The function returns a map with :tokens, containing all tokens (with resolved or unresolved symbols) and :opts for all options in the options map, except :resolve (since that is consumed by tokenize). The reason for having `tokenize` resolving instead of (for instance) `interpret` is that `tokenize` is a macro, which means that is is in the right context to resolve whatever the user code is refering to, while a normal function is not.
(transform transformations interpretation)Transforms an interpretation. Example:
{:col-header [:date :value :value2] :data [["2021-07-01" 10 100] ["2021-07-02" 20 200]] :opts {:coercions {:value double :date t/date :value2 str)} :ns :foo}}
opts is a map of options. Valid options are (applied in this order):
:remove-blank-lines? If true, entries with only blank values are removed.
:coercions A map of keys and functions, where the key represents the attr/column and the function is a function to apply to the values of that key.
:renames A map or renames in the same form as
clojure.set/rename-keys
:ns A keyword that will be the namespace for all keys. Note, that renames are applied before ns.
:format :map - a map with {:col-header header :data data}
:maps - vector of maps with header as keys
:relation - a relation in clojure.set style
:table - a csv-like table with header as first row
opts example:
{:remove-blank-lines? true} :coercions {:date t/date} :renames {:date :from-date} :ns {:some-ns} :format :maps}
Transforms an interpretation. Example:
{:col-header [:date :value :value2]
:data [["2021-07-01" 10 100] ["2021-07-02" 20 200]]
:opts {:coercions {:value double :date t/date :value2 str)}
:ns :foo}}
opts is a map of options. Valid options are (applied in this order):
:remove-blank-lines? If true, entries with only blank values are removed.
:coercions A map of keys and functions, where the key represents
the attr/column and the function is a function to apply
to the values of that key.
:renames A map or renames in the same form as
`clojure.set/rename-keys`
:ns A keyword that will be the namespace for all keys.
Note, that renames are applied before ns.
:format :map - a map with {:col-header header :data data}
:maps - vector of maps with header as keys
:relation - a relation in clojure.set style
:table - a csv-like table with header as first row
opts example:
{:remove-blank-lines? true}
:coercions {:date t/date}
:renames {:date :from-date}
:ns {:some-ns}
:format :maps}
(transformations interpretation)cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |