data.csv
is a Clojure library for reading and writing comma
separated value (csv) files. It is licensed under the Eclipse open
source license.
The library has been tested on Clojure versions 1.2, 1.2.1 and
1.3.
Add
<dependency>
<groupId>org.clojure</groupId>
<artifactId>data.csv</artifactId>
<version>0.1.0</version>
</dependency>
to your pom.xml
file.
Add [org.clojure/data.csv "0.1.0"]
as a dependency to your project.clj
.
(require '[clojure.data.csv :as csv]
'[clojure.java.io :as io])
(with-open [in-file (io/reader "in-file.csv")]
(doall
(csv/read-csv in-file)))
(with-open [out-file (io/writer "out-file.csv")]
(csv/write-csv out-file
[["abc" "def"]
["ghi" "jkl"]]))
data.csv
supports RFC 4180.
Additionally, it is possible to choose separator and quote
characters. Reading is fast and lazy. See (doc read-csv)
for
available options.
See (doc write-csv)
for available options.