Perhaps i'm late to the party on this, but MySQL allows you to have CSV as a storage engine, which is very handy when you're importing lots of CSV. Slides from my lightening talk at the Melbourne Rails meetup.
★ Use familiar tools for dealing with the data ★ Can query the table, so ActiveRecord is happy ★ Can step through the rows can delete each row after processing ★ Feels less volatile ★ No indexes 3 http://dev.mysql.com/doc/refman/5.1/en/csv-storage-engine.html
the engine. Note that everything is a string db_connection.create_table('import_table', :options => 'ENGINE=CSV', :id => false) do |t| # regular migration t.string :id t.text :name t.string :version t.string :platform end
INFILE 'import-stuff.csv' REPLACE INTO TABLE import_stuff FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' STARTING BY ''