Skip to content

Instantly share code, notes, and snippets.

/join-csvs.clj Secret
Created Dec 29, 2013

What would you like to do?
(require '[ :as csv]
'[ :as io])
(defn open-csv [file]
(with-open [in-file (io/reader file)]
(csv/read-csv in-file))))
(defn map-csv-row [fields file]
(map (fn [row] (zipmap fields row))
(open-csv file)))
(defn id-extract [col i]
(merge col
{(:id i) (merge i (get col (:id i)))}))
(defn add-csv
[hm fields file]
(reduce id-extract
(map-csv-row fields file)))
(defn -main []
(add-csv (add-csv {} [:id :first :middle :last] "input.csv")
[:id :age :month] "input2.csv"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.