Saving datasets to CSV and JSON
Once you've done the work of slicing, dicing, cleaning, and aggregating your datasets, you might want to save them. Incanter by itself doesn't have a good way to do this. However, with the help of some Clojure libraries, it's not difficult at all.
Getting ready
We'll need to include a number of dependencies in our project.clj
file:
(defproject inc-dsets "0.1.0" :dependencies [[org.clojure/clojure "1.6.0"] [incanter "1.5.5"] [org.clojure/data.csv "0.1.2"] [org.clojure/data.json "0.2.5"]])
We'll also need to include these libraries in our script or REPL:
(require '[incanter.core :as i] '[incanter.io :as i-io] '[clojure.data.csv :as csv] '[clojure.data.json :as json] '[clojure.java.io :as io])
Also, we'll use the same data that we introduced in the Selecting columns with $ recipe.
How to do it…
This process is really as simple as getting the data and saving it. We'll pull out the...