This question is more about knowing what is returned after applying a
function and the best "functional programming" practices to use in
obtaining particular data in what has been returned.

So, given this program:

(ns test-csv
  (:gen-class)
  (:import (java.io BufferedReader FileReader StringReader))
  (:use clojure-csv.core))

(defn process-file [file-name]
    (with-open [br (BufferedReader. (FileReader. file-name))]
                            (println (parse-csv (line-seq br)))))

(defn -main [& args]
  (process-file "resultset.csv"))

and this data:

"MeterID","Reading","ReadingDateTime","Account","CustomerLN","CustomerFN","DeviceID","DeviceType","ChannelNumber","DecodeType","LoadDateLocal","PremiseID"
33891715,101100,"2011-06-05 23:00:00","610160000","SMITH","E & J",
80581200,43,0,75,"2011-06-06 06:00:01","610160000"
33891773,411200,"2011-06-05 23:00:00","610159000","COMMONER","A",
80598726,43,0,75,"2011-06-06 06:00:01","610159000"
33891887,133100,"2011-06-05 23:00:00","610158000","JONES","J & M",
80581189,43,0,75,"2011-06-06 06:00:01","610158000"
33891825,239400,"2011-06-05 23:00:00","610157000","SAWTOOTH","GEORGE
C",80598731,43,0,75,"2011-06-06 06:00:01","610157000"

and running this:

cnorton@steamboy:~/projects/clojure/test_csv$ ./test-csv

This printed out:

(["MeterID","Reading","ReadingDateTime","Account","CustomerLN","CustomerFN","DeviceID","DeviceType","ChannelNumber","DecodeType","LoadDateLocal","PremiseID"33891715,101100,"2011-06-05
23:00:00","610160000","SMITH","E & J",80581200,43,0,75,"2011-06-06
06:00:01","610160000"33891773,411200,"2011-06-05
23:00:00","610159000","COMMONER","A",80598726,43,0,75,"2011-06-06
06:00:01","610159000"33891887,133100,"2011-06-05
23:00:00","610158000","JONES","J & M",80581189,43,0,75,"2011-06-06
06:00:01","610158000"33891825,239400,"2011-06-05
23:00:00","610157000","SAWTOOTH","GEORGE C",
80598731,43,0,75,"2011-06-06 06:00:01","610157000"])
cn

I have tried various ways using nth and index 0, as well as re-writing
this into a plain file/io example and using clojure.string/split at
comma boundaries, but cannot get a particular column out of each line
in the original file. All efforts so far obtain the first line in the
file and nothing else. I'm trying to figure out how to get the first
column of each line, but it might as well be the nth column of any
line.

The plain I/O method made more sense to me, because after calling map,
because it seemd a sequence of string vectors had been returned, at
least that's how it looked after printing out. The result of printing
the clojure-csv example appears to be one vector. So, I am wondering
how to use clojure-csv to parse out one or more columns in a given
line.

Thanks again for the help.
cmn

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to