Skip to content

Instantly share code, notes, and snippets.

@daveliepmann
Last active August 29, 2015 13:56
Show Gist options
  • Save daveliepmann/9304725 to your computer and use it in GitHub Desktop.
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
(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