Skip to content

Instantly share code, notes, and snippets.

@cjse
Created December 5, 2008 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjse/32335 to your computer and use it in GitHub Desktop.
Save cjse/32335 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment