Help us understand the problem. What is going on with this article?

Clojure clojure.data.csv の使い方

More than 3 years have passed since last update.

CSV の読み書きをするライブラリ。パースした結果はベクタのリストになる。

GitHub
https://github.com/clojure/data.csv
ドキュメント
http://clojure.github.io/data.csv/

(ns clj-data.csv)

(require '[clojure.data.csv :as csv])

(let [filename "usa-states.csv"
      csv (slurp filename)
      rows (csv/read-csv csv)]
  rows)

(let [filename "usa-states.csv"
      csv (slurp filename)
      rows (csv/read-csv csv)]
  (doseq [row rows]
    (let [code (first row)
          name (second row)]
      (println (str code " => " name)))))

(let [filename "test.ltsv"
      csv (slurp filename)
      rows (csv/read-csv csv :separator \tab)]
  (map (fn [row]
         (str (first row) " => " (second row)))
       rows))

(with-out-str
  (csv/write-csv *out* [["foo" "bar"]
                        ["baz" "qux"]]))

(csv/write-csv *out* [["foo" "bar"]
                      ["baz" "qux"]
                      ["I'm" "pen"]]
               :separator \tab)

サンプルコードとサンプルデータ
https://github.com/kyanny/playground/tree/gh-pages/clj-data.csv

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away