Created
October 10, 2014 18:34
-
-
Save MichaelBlume/c67d22df0ff9c225d956 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defn read-to-maps [rows] | |
(let [headers (->> | |
rows | |
first | |
(take-while (complement #{""})) | |
(map keyword))] | |
(for [row (rest rows)] | |
(zipmap headers row)))) | |
(defn read-to-maps-eval [rows] | |
(let [headers (->> | |
rows | |
first | |
(take-while (complement #{""})) | |
(map keyword)) | |
names (map (comp symbol name) headers) | |
mapper (eval | |
`(fn [[~@names]] | |
~(zipmap headers names)))] | |
(map mapper (rest rows)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment