Liking cljdoc? Tell your friends :D

e85th.commons.data.fixed-width

Fixed width file parser. Code adapted from http://www.lexicallyscoped.com/2015/01/05/parsing-flat-files-in-clojure.html.

(def parse-rules {:cols [{:name :company :slice [0 62]} {:name :form :slice [62 74]} {:name :cik :slice [74 86] :type :long} {:name :date :slice [86 98] :type :date} {:name :file :slice [98]}] :skip-lines 10 :skip-line? (some-fn str/blank? (partial re-seq #"^-+$"))})

Fixed width file parser.
   Code adapted from http://www.lexicallyscoped.com/2015/01/05/parsing-flat-files-in-clojure.html.

(def parse-rules
  {:cols [{:name :company
           :slice [0 62]}
          {:name :form
           :slice [62 74]}
          {:name :cik
           :slice [74 86]
           :type :long}
          {:name :date
           :slice [86 98]
           :type :date}
          {:name :file
           :slice [98]}]
   :skip-lines 10
   :skip-line? (some-fn str/blank? (partial re-seq #"^-+$"))})

  
raw docstring

lazy-file-linesclj

(lazy-file-lines file)
file is a string
http://stackoverflow.com/questions/4118123/read-a-very-large-text-file-into-a-list-in-clojure/13312151#13312151
sourceraw docstring

line->column-valclj

(line->column-val line {:keys [name slice parse type]})

Takes a line of text and applies transforms and produces a value.

Takes a line of text and applies transforms and produces a value.
sourceraw docstring

line->mapclj

(line->map {:keys [cols] :as rules} line)

Convert a line to a map

Convert a line to a map
sourceraw docstring

parse-datacljmultimethod

source

parse-fileclj

(parse-file file
            {:keys [skip-line?] :or {skip-line? (constantly false)} :as rules})

file can be a string (path to file), url, or uri.

file can be a string (path to file), url, or uri.
sourceraw docstring

skip-linesclj

(skip-lines n fseq)
source

slice-lineclj

(slice-line line [start end])

line is a string, start and end are ints

line is a string, start and end are ints
sourceraw docstring

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

× close