0

I started a project in Google Spreadsheets. I am now learning Rails instead. But I still have about 1000 records I'd like to import, to kick off my database.

This railcast is great, but I don't need users to do it, and I only need to do it once.

I'd love a one-line solution like this provides for SQL files... except that even if I had an SQL file (not an export option), I wouldn't know where to call that one line.

Thank you.

Community
  • 1
  • 1
bluemihai
  • 405
  • 4
  • 15

1 Answers1

0

Try this:

How to import CSV file data into a PostgreSQL table?

In short you basically setup a CSV file that reflects the structure of the database table you're importing to

If you have to do some manipulation of the data you might find it easier to write something that reads your existing CSV format file and creates database records for each row.

Either using the csv gem or something like this:

https://github.com/pillowfactory/csv-mapper

Community
  • 1
  • 1
Jordan Baker
  • 4,103
  • 1
  • 20
  • 18
  • Cool, there's a [CSV gem](http://ruby-doc.org/stdlib-1.9.3/libdoc/csv/rdoc/CSV.html)! That should be all I need to learn to use then, right? – bluemihai Apr 17 '13 at 19:33