Re: clojure-csv Column or field extraction

2011-06-16 Thread octopusgrabbus
Many thanks. On Jun 16, 12:18 pm, David Santiago wrote: > Change the first line to something like (def csv (parse-csv (slurp > "path/to/my/file.csv"))). > >   -  David > > On Thu, Jun 16, 2011 at 8:20 AM, octopusgrabbus > > > > > > > > wrote: > > I would like to modify the examples given > > > u

Re: clojure-csv Column or field extraction

2011-06-16 Thread David Santiago
Change the first line to something like (def csv (parse-csv (slurp "path/to/my/file.csv"))). - David On Thu, Jun 16, 2011 at 8:20 AM, octopusgrabbus wrote: > I would like to modify the examples given > > user=> (def csv (parse-csv "1,2,3\n4,5,6\n7,8,9")) > #'user/csv > user=> (nth (nth csv 1)

Re: clojure-csv Column or field extraction

2011-06-16 Thread octopusgrabbus
I would like to modify the examples given user=> (def csv (parse-csv "1,2,3\n4,5,6\n7,8,9")) #'user/csv user=> (nth (nth csv 1) 2) ;; Get 2nd row, last column. "6" user=> (-> csv (nth 1) (nth 2)) ;; Another way to do it. "6" user=> (defn get-column [parsed-csv col] (map #(nth % col) parsed-csv))

Re: clojure-csv Column or field extraction

2011-06-15 Thread David Santiago
Here's a repl session that will hopefully demonstrate how to do a few things, including pull out an entire column. Just remember the library turns CSVs into regular clojure data structures, so getting the data you want out of the return value of the parse is just about indexing into vectors. user=

Re: clojure-csv Column or field extraction

2011-06-15 Thread octopusgrabbus
I've got to go back and look at your documentation. I'm not sure how to pull the columns out of each row. On Jun 15, 5:04 pm, David Santiago wrote: > I'm afraid I don't understand the question. What do you mean > "positionally?" When it parses the CSV file, it gives you back a > stream of rows, e

Re: clojure-csv Column or field extraction

2011-06-15 Thread David Santiago
I'm afraid I don't understand the question. What do you mean "positionally?" When it parses the CSV file, it gives you back a stream of rows, each row being a vector of the contents of each cell of the CSV. If you are interested in cells at a given row/column, you should be able to count into those

clojure-csv Column or field extraction

2011-06-15 Thread octopusgrabbus
Is it possible to use clojure-csv to extract data positionally in a .csv file, or should I use BufferedReader to read each line lazily and apply splitting the line up into fields by delimiter? Thanks. cmn -- You received this message because you are subscribed to the Google Groups "Clojure" grou