lib
called csvs
lib/csvs
folder. In the example below, the file is called real_estate_transactions.csv
Transaction
. The column names in your model don't have to match up exactly with the headings in the CSV.rails slurp:transactions
which will slurp the data from real_estate_transactions.csv
and put it in our database.lib/tasks/slurp.rake
that looks like this:task transactions: :environment do
and the first end
:rails slurp:transactions
you should see a wall of text representing your CSV data. It's a first step, but we've still got a lot of work to do.rails slurp:transactions
at the end of each step:headers => true
option tells the parser that the first line in the file has column headings in it, not a row of data.:headers => true
option in our previous step.