Created
April 8, 2021 10:58
-
-
Save evilsneer/621cd82a258b1e571d0929838285bea3 to your computer and use it in GitHub Desktop.
Clojure seq of maps -> csv
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
(defn write-csv [writer row-data] | |
(let [columns (->> | |
row-data | |
first | |
(into (sorted-map)) | |
keys) | |
headers (map name columns) | |
rows (->> row-data | |
(map (comp vals #(into (sorted-map) %))))] | |
(csv/write-csv writer (lazy-seq (cons headers rows))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment