Created
January 5, 2023 13:09
-
-
Save equivalent/06977eb934b04e4a5f7f5304a3c40d6d to your computer and use it in GitHub Desktop.
how to generare CSV for milion records in sidekiq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Model.pluck(:id, :name, ...).find_in_batches(10_000) do |ary| | |
CSV.open("tmp.csv", "ab") do |csv| | |
csv << ary.map{|a| a.join ','}.join("\n") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/56362259/generating-csv-excel-file-for-100-million-of-records-in-ruby-on-rails