Liking cljdoc? Tell your friends :D
Clojure only.

datahike-csv-loader.core


load-csvclj

(load-csv csv-file)
(load-csv csv-file cfg)
(load-csv csv-file cfg {:keys [schema ref-map tuple-map composite-tuple-map]})

Reads, parses, and loads data from CSV file named csv-file into the Datahike database having (optionally specified) config cfg, with likewise optional schema-related options for the corresponding attributes. Each column represents an attribute, with keywordized column name as attribute ident, or otherwise, an element in a heterogeneous or homogeneous tuple.

If cfg is omitted, and the last argument:

  1. is also absent, or has empty :schema, :ref-map, and :composite-tuple-map, cfg is inferred to be {:schema-flexibility :read}.
  2. has a non-empty value for one or more of :schema, :ref-map, and :composite-tuple-map, cfg is inferred to be {}, i.e. the default value.

:schema in the last argument can be specified in two ways:

  1. Full specification via the usual Datahike transaction data format, i.e. a vector of maps, each corresponding to an attribute.
  2. Partial specification via an abridged format like the map returned by datahike.api/reverse-schema, albeit with slightly different keys, each having a set of attribute idents as the corresponding value. Available options:
KeyDescription
:unique-id:db/unique value :db.unique/identity
:unique-val:db/unique value :db.unique/value
:index:db/index value true
:cardinality-many:db/cardinality value :db.cardinality/many

Ref- and tuple-valued attributes, i.e. those with :db/valueType :db.type/ref or :db.type/tuple, are however specified separately, via :ref-map, :tuple-map, or :composite-tuple-map, each a map as follows:

KeyDescription
:ref-map:db.type/ref attribute idents to referenced attribute idents
:composite-tuple-mapComposite :db.type/tuple attribute idents to constituent attribute idents
:tuple-mapOther (homogeneous, heterogeneous) :db.type/tuple attribute idents to constituent attribute idents

Unspecified schema attribute values are defaults or inferred from the data given.

Example invocations:

(load-csv csv-file)
(load-csv csv-file dh-cfg)
(load-csv csv-file dh-cfg {:schema [{:db/ident :name
                                     ...}
                                    ...]
                           :ref-map {...}
                           :tuple-map {...}
                           :composite-tuple-map {...}})
(load-csv csv-file dh-cfg {:schema {:unique-id #{...}
                                    ...}
                           :ref-map {...}
                           :tuple-map {...}
                           :composite-tuple-map {...}})

Please see README for more detail.

Reads, parses, and loads data from CSV file named `csv-file` into the Datahike database having
(optionally specified) config `cfg`, with likewise optional schema-related options for the
corresponding attributes. Each column represents an attribute, with keywordized column name as
attribute ident, or otherwise, an element in a heterogeneous or homogeneous tuple.

If `cfg` is omitted, and the last argument:
1. is also absent, or has empty `:schema`, `:ref-map`, and `:composite-tuple-map`, `cfg` is inferred to be `{:schema-flexibility :read}`.
2. has a non-empty value for one or more of `:schema`, `:ref-map`, and `:composite-tuple-map`, `cfg` is inferred to be `{}`, i.e. the default value.

`:schema` in the last argument can be specified in two ways:
1. Full specification via the usual Datahike transaction data format, i.e. a vector of maps,
each corresponding to an attribute.
2. Partial specification via an abridged format like the map returned by `datahike.api/reverse-schema`,
albeit with slightly different keys, each having a set of attribute idents as the corresponding value.
Available options:

| Key                 | Description   |
|---------------------|---------------|
| `:unique-id`        | `:db/unique` value `:db.unique/identity`
| `:unique-val`       | `:db/unique` value `:db.unique/value`
| `:index`            | `:db/index` value `true`
| `:cardinality-many` | `:db/cardinality` value `:db.cardinality/many`

Ref- and tuple-valued attributes, i.e. those with `:db/valueType` `:db.type/ref` or `:db.type/tuple`, are
however specified separately, via `:ref-map`, `:tuple-map`, or `:composite-tuple-map`, each a map as follows:

| Key                     | Description   |
|-------------------------|---------------|
| `:ref-map`              | `:db.type/ref` attribute idents to referenced attribute idents
| `:composite-tuple-map`  | Composite `:db.type/tuple` attribute idents to constituent attribute idents
| `:tuple-map`            | Other (homogeneous, heterogeneous) `:db.type/tuple` attribute idents to constituent attribute idents

Unspecified schema attribute values are defaults or inferred from the data given.

Example invocations:
``` clojure
(load-csv csv-file)
(load-csv csv-file dh-cfg)
(load-csv csv-file dh-cfg {:schema [{:db/ident :name
                                     ...}
                                    ...]
                           :ref-map {...}
                           :tuple-map {...}
                           :composite-tuple-map {...}})
(load-csv csv-file dh-cfg {:schema {:unique-id #{...}
                                    ...}
                           :ref-map {...}
                           :tuple-map {...}
                           :composite-tuple-map {...}})
```

Please see README for more detail.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close