Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- path = "/Users/cj/Desktop/prisma.csv"
- require 'csv'
- CSV.open(path, 'r') do |row|
- if @headers.nil?
- @headers = row.map(&:to_sym)
- else
- e = Employee.new
- attributes = Hash[*@headers.zip(row).flatten]
- @headers.each do |header|
- e.send "#{header}=", attributes[header]
- end
- e.save
- end
- end
Add Comment
Please, Sign In to add comment