back

Quickly export a table to CSV in the rails console with FasterCSV

You could do this in MYSQL, or you could do it in Ruby:

1
2
3
4
5
6
7
8
9
10

require 'fastercsv'

FasterCSV.open("file.csv", "w") do |csv|
  Model.all.each do |object|
    csv << object.attributes.values
  end
end


June 24, 2009