Last active
December 19, 2015 13:58
-
-
Save westonwatson/5965593 to your computer and use it in GitHub Desktop.
import using FasterCSV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
desc "load user data from csv" | |
task :load_csv_data => :environment do | |
require 'fastercsv' | |
FasterCSV.foreach("data.csv") do |row| | |
User.create( | |
:user_name => row[0], | |
:email => row[1], | |
:password => row[2] | |
) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
out of date, i believe that FasterCSV was implented as the standard CSV lib now. so it's just CSV, not FastCSV anymore...