Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. require 'csv'
  2.  
  3. task import: :environment do
  4. csv = CSV.foreach('/home/diego/work/data/itcont.txt') do |row|
  5. ActiveRecord::Base.transaction do
  6. t = Transaction.new
  7. t.build_contributor(name: row[7], city: row[8], state: row[9], zip_code: row[10], employer: row[11], occupation: row[12])
  8. t.build_contribution(cmte_id: row[0])
  9. t.save
  10. end
  11. end
  12. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement