Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
14
Task/CSV-data-manipulation/Clojure/csv-data-manipulation.clj
Normal file
14
Task/CSV-data-manipulation/Clojure/csv-data-manipulation.clj
Normal file
|
|
@ -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)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue