Created
June 5, 2015 21:28
-
-
Save dchelimsky/682310d2bc9826357911 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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