Reputation: 107
I'm reading values from one csv file using FasterCSV gem and doing some operations and dumping the same data to a different csv file by adding one additional column which specifies the status of the each row. Below is the code for the same
path ="#{RAILS_ROOT}/data/reports/file1.csv"
output_path = "#{RAILS_ROOT}/data/reports/file2.csv"
FasterCSV.open(output_path, "w") do |csv|
FasterCSV.foreach(path,:headers => false) do |row|
if self.import_file_has_header == true
if starting_row == 0
row << "Status"
csv << row
starting_row = starting_row + 1
next
end
end
ActiveRecord::Base.transaction do
# doing some operations
end
row << "Success"
csv << row
end
end
even the operations were successful in a transaction, there was a delay in dumping data ,this one observed when downloaded the file, which shows 0 MB at begining after some time size of the file is growing and for some time it will be of same size and the process will be continued. Is there any reason for this or am I doing anything wrong ?
I am using ruby 1.8.7 and fastercsv (1.5.4).
Upvotes: 0
Views: 81