Liking cljdoc? Tell your friends :D

ultra-csv.core


close!clj

(close! f)

Closes and cleans the io ressources used. Can be used on a greedy generator or any line of a lazy seqs of results

Closes and cleans the io ressources used. Can be used on a greedy generator or any
line of a lazy seqs of results
sourceraw docstring

csv-lineclj

(csv-line spec data)
source

csv-line-readerclj

(csv-line-reader {:keys [header? field-names schema guess-types? strict?
                         counter-step silent? limit nullable-fields? coercers]
                  :or {guess-types? true strict? true coercers {}}
                  :as opts})

This function returns a reader function that accepts inputs of one String line at a time. It takes the same options as read-csv minus some processing and the file and analysis options.

This function returns a reader function that accepts inputs of one *String* line at a time.
It takes the same options as [[read-csv]] minus some processing and the file and analysis options.
sourceraw docstring

guess-specclj

(guess-spec uri)
(guess-spec
  uri
  {:keys [header? field-names field-names-fn schema encoding guess-types?
          delimiter nullable-fields? keywordize-keys? sample-size bom skip]
   :or {guess-types? true nullable-fields? 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 as 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

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
  • nullable-fields?: Whether the values are optionals. Defaults to true
  • keywordize-keys?: Whether to turn fields into keywords. Defaults to true

Format options

  • delimiter: Character used as a delimiter
  • schema: Schema to validate and coerce output
  • field-names: Names for the csv fields, in order
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 as 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

 *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
 +  **nullable-fields?**: Whether the values are optionals. Defaults to *true*
 +  **keywordize-keys?**: Whether to turn fields into keywords. Defaults to *true*

 *Format options*

 +  **delimiter**: Character used as a delimiter
 +  **schema**: Schema to validate and coerce output
 +  **field-names**: Names for the csv fields, in order
sourceraw docstring

load-spec-strclj

(load-spec-str spec-string)

Loads a spec structure from String form. BEWARE The uses eval on the passed String, only use on inputs that are ABSOLUTELY SAFE

Loads a spec structure from String form. **BEWARE** The uses eval
on the passed String, only use on inputs that are **ABSOLUTELY SAFE**
sourceraw docstring

make-date-coercerclj

(make-date-coercer fmt)
(make-date-coercer fmt timezone)

Makes a date coercer to use with the coercer option of read-csv. Given a formatter String and an optional timezonr String, this will return a ready to use function. Details on the format can be found at http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Makes a date coercer to use with the *coercer* option of [[read-csv]].
Given a formatter *String* and an optional timezonr *String*, this will return
a ready to use function. Details on the format can be found at
http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
sourceraw docstring

read-csvclj

(read-csv uri)
(read-csv uri
          {:keys [header? field-names field-names-fn schema encoding
                  guess-types? strict? greedy? counter-step silent? limit
                  skip-analysis? nullable-fields? keywordize-keys? coercers bom
                  skip]
           :or {guess-types? true
                strict? true
                nullable-fields? true
                keywordize-keys? true
                coercers {}
                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 as 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

Processing options

  • greedy?: If true returns a function that can be used as a generator, returning one line with each call, else returns a lazy seq of lines. Defaults to false
  • strict?: Whether to throw exception on reading of validation error, or just skip it. Defaults to true
  • silent?: Whether there should be error messages emitted on stderr when skipping Exceptions. Defaults to false
  • limit: Closes and cleans the io ressources after reading this many lines. Useful for sampling
  • field-names-fn: fn to apply to the name of each field. Can be used to sanitize header names. Defaults to trim function
  • nullable-fields?: Whether the values are optionals. Defaults to true
  • keywordize-keys?: Whether to turn fields into keywords. Defaults to true

Format options

  • delimiter: Character used as a delimiter

  • schema: Schema to validate and coerce output

  • coercers: A map associating a type as key with a function from String to that type. For example:

    {:coercers {java.util.Date (make-date-coercer "yyyyMMdd")}}
    
  • field-names: Names for the csv fields, in order

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 as 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

*Processing options*

+  **greedy?**: If true returns a function that can be used as a generator, returning one line
   with each call, else returns a lazy seq of lines. Defaults to *false*
+  **strict?**: Whether to throw exception on reading of validation error, or just skip it.
   Defaults to *true*
+  **silent?**: Whether there should be error messages emitted on *stderr* when skipping Exceptions.
   Defaults to *false*
+  **limit**: Closes and cleans the io ressources after reading this many lines. Useful for
   sampling
+  **field-names-fn**: fn to apply to the name of each field. Can be used to sanitize header
   names. Defaults to trim function
+  **nullable-fields?**: Whether the values are optionals. Defaults to *true*
+  **keywordize-keys?**: Whether to turn fields into keywords. Defaults to *true*

*Format options*

+  **delimiter**: Character used as a delimiter
+  **schema**: Schema to validate and coerce output
+  **coercers**: A map associating a type as key with a function from *String* to that type.
   For example:

       {:coercers {java.util.Date (make-date-coercer "yyyyMMdd")}}

+  **field-names**: Names for the csv fields, in order
sourceraw docstring

write-csv!clj

(write-csv! uri data)
(write-csv! uri
            {:keys [bom encoding field-names coercers header? append]
             :as spec
             :or {bom :none header? true}}
            data)

This function takes a target (either a Reader, InputStream or String URI), a spec of options and a seq of either maps or seqs. Each data structure is written to the target csv as a single line.

Right now, custom encoders are ignored and each value is just coerced to its String format.

The option map is the same as read-csv with these added options:

Write options

  • append: if set to true, opens the given uri in append mode. header? option is then ignored.
This function takes a target (either a *Reader*, *InputStream* or *String* URI), a spec of options
and a seq of either *maps* or *seqs*. Each data structure is written to the target csv
as a single line.

Right now, custom encoders are ignored and each value is just coerced to its *String* format.

The option map is the same as [[read-csv]] with these added options:

*Write options*

+  **append**: if set to true, opens the given uri in append mode. *header?* option is then
   ignored.
sourceraw docstring

write-specclj

(write-spec spec)

Writes a spec struct to a String

Writes a spec struct to a String
sourceraw docstring

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

× close