I have a large CSV file that contains independent elements that require a lot of effort to process. I would like to be able to process each position in parallel. I found sample code for processing a CSV file on SO here:
Beginner Converts CSV Files to Clojure
The code:
(use '(clojure.contrib duck-streams str-utils)) ;;' (with-out-writer "coords.txt" (doseq [line (read-lines "coords.csv")] (let [[xyzp] (re-split
It managed to print data from my CSV file, which was great - but it only used one processor. I tried different things, in the end:
(pmap println (read-lines "foo"))
This works fine interactively, but does nothing when run from the command line. From a conversation in IRC, this is because stdout is not available for streams by default.
Indeed, what I'm looking for is a way to idiomatically apply a function to each line of a CSV file and do it in parallel. I would also like to print some results for stdout during testing, if at all possible.
Any ideas?
concurrency clojure
PeterM
source share