Something like
(with-open [rdr (clojure.java.io/reader "/dev/errors-sunday.csv")]
(->> (line-seq rdr)
(filter #(re-matches #"..."))
(map #(nth (string/split % #",") 1))))
Will do what you want. It's laziness to the rescue.
On Tue, Mar 4, 2014 at 3:21 PM, Dean Laskin <[email protected]> wrote:
> I'm comparing two large files based on specific fields in the files. Is
> there a functional way of accumulating the results without atoms? (And
> since I'm a newbie, any other advice is appreciated!)
>
> (let [sun (atom []) fri (atom [])]
> (with-open [rdr (clojure.java.io/reader "/dev/errors-sunday.csv")]
> (doseq [line (line-seq rdr)]
> (when (re-matches #"^[^,]+,[^,]+,FAIL,.*$" line)
> (swap! sun conj (nth (string/split line #",") 1)))))
> (with-open [rdr (clojure.java.io/reader "/dev/errors-friday.csv")]
> (doseq [line (line-seq rdr)]
> (when (re-matches #"^[^,]+,[^,]+,FAIL,.*$" line)
> (swap! fri conj (nth (string/split line #",") 1)))))
> (println (nth (data/diff (set @fri) (set @sun)) 1))
> )
>
> Thanks,
> Dean
>
> --
> 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/groups/opt_out.
>
--
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/groups/opt_out.