How can I cut down on the size of file loaded into Roo object in Rails?

89 views Asked by At

I am using the roo gem to parse data in a CSV. The CSV is around 400MB in size however, and when I attempt to parse it with this loop...

(2..sheet.last_row).collect do |i|
   # parsing code...
end

It will error out with [FATAL] failed to allocate memory. I was going to break it up with smaller loops until it reaches the last_row, but just asking roo for the last_row will cause the error -- so I can't really tackle it that way.

0

There are 0 answers