Clojure Cookbook: Regular Expressions

Parsing CSV Files


How do I parse the lines of a comma-separated value file?

(defn parse-line [s]
(map (fn [[a b c]] (or b c)) (re-seq #"(?:([^\",]+)|\"((?:[^\"]|\\\")*)\")" s)))

Back to Clojure Cookbook: Table of Contents


Add a New Comment
or Sign in as Wikidot user
(will not be published)
- +

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License