Reputation: 6003
I want to read file out in chuck, and then insert them into database. Since if insert one record a time is slow, so I'd like to insert 1000 records a time, but how to do it using doseq?
(with-open [rdr (io/reader file-name)]
(doseq [line (line-seq rdr)]
;;how to split them in chuck lazily. so that not use too much memory.
Upvotes: 0
Views: 371
Reputation: 3014
(with-open [rdr (io/reader file-name)]
(doseq [chunk (partition 1000 (line-seq rdr))]
;;Make an INSERT for all the lines in chunk
seems like it should work nicely.
Upvotes: 2