update csv import job

This commit is contained in:
Dylan Knutson
2023-08-24 15:03:00 -07:00
parent ca8e69e9bc
commit 3f516938c2
10 changed files with 360 additions and 196 deletions

View File

@@ -155,3 +155,13 @@ task :workoff_failed_jobs => [:environment, :set_ar_stdout, :set_logger_stdout]
worker.run(job)
end
end
task :reverse_csv do
file = ENV["file"] || raise("need 'file' (file path)")
in_csv = CSV.parse(File.open(file, "r+"), headers: true)
out_csv = CSV.new(File.open("rev_" + file, "w"), write_headers: true, headers: in_csv.headers)
in_csv.reverse_each do |row|
out_csv << row.map(&:second)
end
out_csv.close
end