Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,14 @@
|
|||
(require '[clojure.data.csv :as csv]
|
||||
'[clojure.java.io :as io])
|
||||
|
||||
(defn add-sum-column [coll]
|
||||
(let [titles (first coll)
|
||||
values (rest coll)]
|
||||
(cons (conj titles "SUM")
|
||||
(map #(conj % (reduce + (map read-string %))) values))))
|
||||
|
||||
(with-open [in-file (io/reader "test_in.csv")]
|
||||
(doall
|
||||
(let [out-data (add-sum-column (csv/read-csv in-file))]
|
||||
(with-open [out-file (io/writer "test_out.csv")]
|
||||
(csv/write-csv out-file out-data)))))
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
(require '[tech.v3.dataset :as ds]
|
||||
'[tech.v3.datatype.functional :as dfn])
|
||||
|
||||
(defn add-sum
|
||||
[dataframe]
|
||||
(assoc dataframe
|
||||
"SUM"
|
||||
(apply dfn/+ (map dataframe (ds/column-names dataframe)))))
|
||||
|
||||
(ds/write! (add-sum (ds/->dataset "resources/input.csv")) "resources/output.csv")
|
||||
Loading…
Add table
Add a link
Reference in a new issue