Skip to content

Instantly share code, notes, and snippets.

@dwillis
Created February 29, 2012 20:02
Show Gist options
  • Select an option

  • Save dwillis/1944026 to your computer and use it in GitHub Desktop.

Select an option

Save dwillis/1944026 to your computer and use it in GitHub Desktop.
def self.load_from_csv
columns = column_names.reject{|c| ["created_at", "updated_at", "id"].include?(c)}
values = []
FasterCSV.foreach("#{Rails.root}/db/data/my_file.csv", :headers => true) do |row|
values << row
end
import(columns, values, :validate => false, :on_duplicate_key_update => [:field_one, :field_two])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment