clojure:how 从文件中读取块中的数据

clojure:how to read data in chunk from a file

我想在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.
(with-open [rdr (io/reader file-name)]
  (doseq [chunk (partition 1000 (line-seq rdr))]
    ;;Make an INSERT for all the lines in chunk

看起来它应该工作得很好。