Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A lazy opencsv wrapper in clojure
Clojure
tree: 3714116682

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src/opencsv_clj
test
.gitignore
README.md
project.clj

README.md

opencsv-clj

A lazy opencsv (http://opencsv.sourceforge.net/) wrapper in Clojure

Usage

(require '[opencsv-clj.core :as csv])

Get a lazy seq of the lines from a csv file: (csv/parse-file "filename")

or directly from a string: (csv/parse-string "a,b,c") => (["a" "b" "c"])

or from any reader you want, really: (csv/parse (MyAwesomeReader.))

These three functions can take three options:

  • :mapped - when true, the function returns a map for each line with the csv's header (first line) as keys (default: false)

    (get (second (csv/parse-string "1,2,3\n2,4,6\n3,6,9" :mapped true)) "2") ==> "6"

  • :delimiter - the delimiterchar used by the parser (default \,)

    (csv/parse-string "a+b+c" :delimiter +) => (["a" "b" "c"])

  • :quoter - the quote character used by the parser (default \")

    (csv/parse-string "'a,a,a','1,2,3','I,II,III'" :quoter \') => (["a,a,a" "1,2,3" "I,II,III"])

Installation

Leiningen:

[opencsv-clj "1.2.1"]

Maven:

<dependency>
  <groupId>opencsv-clj</groupId>
  <artifactId>opencsv-clj</artifactId>
  <version>1.2.1</version>
</dependency>

Contributors

License

Copyright (C) 2010 Sidhant Godiwala

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.