Liking cljdoc? Tell your friends :D

meta-csv.core


base-typesclj

source

default-postprocess-fnclj

source

default-preprocess-fnclj

source

default-write-fnclj

(default-write-fn v)
source

guess-specclj

(guess-spec uri)
(guess-spec uri
            {:keys [header? fields field-names-fn encoding guess-types?
                    delimiter sample-size bom skip]
             :or {guess-types? true sample-size 100 skip 0}
             :as opts})

This function takes a source of csv lines (either a Reader, InputStream or String URI) and tries to guess the specs necessary to parse it. You can use the option map to specify some values for the spec. Recognised options are:

Analysis options

  • :header?: Whether the file has a header on the first line
  • :sample-size: number of lines on which heuristics are applied. Defaults to 100
  • :guess-types?: Whether to try to guess types for each field. Defaults to true
  • :skip: Number of lines to skip before starting to parse. Defaults to 0

Schema options

In a :fields key, the seq of fields specs you want to override in the inference process. Mostly used to specify manually name of column or type for special needs. The same effect cab be had by editing the resulting spec. Fields specs are maps with the following keys:

  • :field: The name of the column in the results
  • :type: the type to use for coercing the value. Can be one of (:float :percent :double :long :integer :string)

A nil field spec means to skip this column in the results. An empty map means full inference for this field. A Keyword or String instead of a map simply defines the name of the column in the results.

Example:

{:fields [{:type :string :field :my-field-name} nil {} {:type :float :field :my-float-field}]}

File options

  • :encoding: Character encoding for the file

Processing options

  • :field-names-fn: fn to apply to the name of each field. Defaults to trim function

Format options

  • :delimiter: Character used as a delimiter
This function takes a source of csv lines (either a *Reader*, *InputStream* or *String* URI)
and tries to guess the specs necessary to parse it. You can use the option map to specify some values
for the spec. Recognised options are:

 *Analysis options*

  +  **:header?**: Whether the file has a header on the first line
  +  **:sample-size**: number of lines on which heuristics are applied. Defaults to *100*
  +  **:guess-types?**: Whether to try to guess types for each field. Defaults to *true*
  +  **:skip**: Number of lines to skip before starting to parse. Defaults to 0

 *Schema options*

  In  a **:fields** key, the seq of fields specs you want to override in the inference process.
  Mostly used to specify manually name of column or type for special needs. The same effect cab be had by editing the resulting spec.
  Fields specs are maps with the following keys:

  + **:field**: The name of the column in the results
  + **:type**: the type to use for coercing the value. Can be one of (:float :percent :double :long :integer :string)

  A *nil* field spec means to skip this column in the results.
  An empty map means full inference for this field.
  A *Keyword* or *String* instead of a map simply defines the name of the column in the results.

  Example:
  ```clojure
  {:fields [{:type :string :field :my-field-name} nil {} {:type :float :field :my-float-field}]}
  ```

 *File options*

  +  **:encoding**: Character encoding for the file

 *Processing options*

  +  **:field-names-fn**: fn to apply to the name of each field. Defaults to trim function

 *Format options*

  +  **:delimiter**: Character used as a delimiter
sourceraw docstring

read-csvclj

(read-csv uri)
(read-csv uri
          {:keys [header? field-names-fn fields encoding guess-types?
                  skip-analysis? bom skip null]
           :or {guess-types? true skip 0}
           :as opts})

This function takes a source of csv lines (either a Reader, InputStream or String URI) and returns the parsed results. If headers are found on the file or field names where given as options, it will return a collection of one map per line, associating each field name with its value. If not, one vector will be returned for each line, in order.

You can use the option map to specify some values for the spec. Recognised options are:

Analysis options

  • header?: Whether the file has a header on the first line
  • sample-size: number of lines on which heuristics are applied. Defaults to 100
  • guess-types?: Whether to try to guess types for each field. Defaults to true
  • skip-analysis?: Whether to completely bypass analysis and only use spec Defaults to false
  • skip: Number of lines to skip before starting to parse. Defaults to 0
  • null: String or set of strings to be coerced to nil

Schema options

In a :fields key, the seq of fields specs you want to override in the inference process. Mostly used to specify manually name of column or type for special needs. Fields specs are maps with the following keys:

  • :field: The name of the column in the results
  • :type: the type to use for coercing the value. Can be one of :float :percent :double :long :integer :string
  • :preprocess-fn: function applied to value as strings, before type coercion. Defaults to (fn [^String v] str/trim)
  • :postprocess-fn: function applied to values after type coercion. Defaults to identity

A nil field spec means to skip this column in the results. An empty map means full inference for this field. A Keyword or String instead of a map simply defines the name of the column in the results.

Example:

{:fields [{:type :string :field :my-field-name} nil {} {:type :float :field :my-float-field}]}

Processing options

  • field-names-fn: fn to apply to the name of each field. Can be used to sanitize header names. Defaults to trim function

Format options

  • delimiter: Character used as a delimiter
This function takes a source of csv lines (either a *Reader*, *InputStream* or *String* URI)
 and returns the parsed results. If headers are found on the file or field names where given
 as options, it will return a collection of one map per line, associating each field name with
 its value. If not, one vector will be returned for each line, in order.

You can use the option map to specify some values for the spec. Recognised options are:

*Analysis options*

+  **header?**: Whether the file has a header on the first line
+  **sample-size**: number of lines on which heuristics are applied. Defaults to *100*
+  **guess-types?**: Whether to try to guess types for each field. Defaults to *true*
+  **skip-analysis?**: Whether to completely bypass analysis and only use spec
   Defaults to *false*
+  **skip**: Number of lines to skip before starting to parse. Defaults to 0
+  **null**: String or set of strings to be coerced to nil

*Schema options*

 In  a **:fields** key, the seq of fields specs you want to override in the inference process.
 Mostly used to specify manually name of column or type for special needs.
 Fields specs are maps with the following keys:

 + **:field**: The name of the column in the results
 + **:type**: the type to use for coercing the value. Can be one of :float :percent :double :long :integer :string
 + **:preprocess-fn**: function applied to value as strings, before type coercion. Defaults to (fn [^String v] str/trim)
 + **:postprocess-fn**: function applied to values after type coercion. Defaults to *identity*

 A *nil* field spec means to skip this column in the results.
 An empty map means full inference for this field.
 A *Keyword* or *String* instead of a map simply defines the name of the column in the results.

 Example:
 ```clojure
 {:fields [{:type :string :field :my-field-name} nil {} {:type :float :field :my-float-field}]}
 ```

*Processing options*

+  **field-names-fn**: fn to apply to the name of each field. Can be used to sanitize header
   names. Defaults to trim function

*Format options*

+  **delimiter**: Character used as a delimiter
sourceraw docstring

row->cljclj

(row->clj row
          {:keys [fields field-names-fn named-fields? skip null] :or {skip 0}})
source

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

× close