我想在chuck中读取文件,然后将它们插入数据库。因为如果插入一条记录的时间很慢,那么我想一次插入1000条记录,但是如何使用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.
答案 0 :(得分:2)
(with-open [rdr (io/reader file-name)]
(doseq [chunk (partition 1000 (line-seq rdr))]
;;Make an INSERT for all the lines in chunk
好像应该很好用。