My CSV file is something like the attached file which could have 'n' number
of line. I need to group by the values in the last column.
Current I believe the below code will return me a vector of vector.
(defn read-csv-file
[path]
(try
(with-open [input-file (io/reader path)]
(let [a_list (doall (map (comp first clojure-csv.core/parse-csv) (line-
seq input-file)))]
(rest (into [] a_list))))
(catch Exception exception (throw exception))))
i need to iterate through this vector of vector and create a new vector of
vector containing only elements of the first group, then in next iteration
i need the second set and so on.
Example CSV
> Heading1 Heading 2 Heading 3
> abc 123 Value1
> def 234 Value1
> ghi dfgew Value1
> jkl 456 Value5
> pqr 567 Value5
> stu 678 value3
> vwx sdf value4
> yza 900 value4
so when this CSV is parsed i will have something like
[
[abc 123 Value1]
[def 234 Value1]
[ghi dfgew Value1]
[jkl 456 Value5]
[pqr 567 Value5]
[stu 678 value3]
[vwx sdf value4]
[yza 900 value4]]
So when i iterate through this i need to group the vector of vector by the
last column
so my first iteration output should be something like
[
[abc 123 Value1]
[def 234 Value1]
[ghi dfgew Value1]]
2nd iteration should be
[
[jkl 456 Value5]
[pqr 567 Value5]]
3rd should be
[
[stu 678 value3]]
and so on.
How would i achieve this in clojure. is there any build in csv parsing
function
Regards
JP
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.