Last active
August 29, 2015 13:56
-
-
Save daveliepmann/9304725 to your computer and use it in GitHub Desktop.
Clojurey and CSV-oriented version of Jack Rusher's elispy tsv-to-sexp: https://gist.github.com/jackrusher/5467833
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 csv-to-sexp | |
"Parses the string `csv` as a comma-separated-value file, | |
returning a sexp containing the values with strings converted to | |
numbers where appropriate." | |
[csv] | |
(map (fn [s] (map #(let [i (string/trim %) | |
r-s (read-string i)] | |
(if (number? r-s) r-s i)) (string/split s #","))) | |
(string/split-lines csv))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment