samedi 12 septembre 2015

Most memory-efficient way to write huge file row-by-row in Rails application

What is the most memory-efficient way to write huge file row-by-row in Rails application?

Code looks like this, but I think there must be more memory-efficient method. Maybe it is writing to the file without loading it into memory.

  def initialize
    @file = File.open(filename, 'a')
  end

  def foo
    @file << text
  end

  def body
    1000000.times { foo }
  end

Aucun commentaire:

Enregistrer un commentaire