Skip to content

Instantly share code, notes, and snippets.

@dchelimsky
Created June 5, 2015 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dchelimsky/682310d2bc9826357911 to your computer and use it in GitHub Desktop.
Save dchelimsky/682310d2bc9826357911 to your computer and use it in GitHub Desktop.
diff --git a/src/semantic_csv/core.clj b/src/semantic_csv/core.clj
index bfb3972..6f780cb 100644
--- a/src/semantic_csv/core.clj
+++ b/src/semantic_csv/core.clj
@@ -213,6 +213,19 @@
;; pipeline.
+;; input - lazy seq of rows
+;; out - map of col-names to casting-fns
+;; optional args - n-lines
+;; default-casting-fn
+;; (cast-with-sniffer {:n-lines 20 :default str :overrides {:col-name fn}} csv-data)
+;; (->> csv-data
+;; (map x ...)
+;; (tranduce transducing-fn ...)
+;; (sniff {:n-lines 20 :default str :overrides {:col-10 int}}))
+(defn sniff )
+(as-> coll xs
+ (map f xs)
+ (filter #(thing with xs) xs))
;; <br />
;; ## except-first
@@ -252,6 +265,16 @@
;; <br/>
;; ## process
+ (def foo (comp
+ remove-comments
+ mappify
+ (cast-with {:this #(Integer/parseInt %)})
+ doall))
+
+(with-open [in-file (io/reader "test/test.csv")]
+ (transduce foo (csv/parse-csv in-file))
+)
+
(defn process
"This function wraps together the most frequently used input processing capabilities,
controlled by an `opts` hash with opinionated defaults:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment