Skip to content

Instantly share code, notes, and snippets.

@MichaelBlume
Created October 10, 2014 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelBlume/c67d22df0ff9c225d956 to your computer and use it in GitHub Desktop.
Save MichaelBlume/c67d22df0ff9c225d956 to your computer and use it in GitHub Desktop.
(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