Skip to content

Instantly share code, notes, and snippets.

@wannabefro
Created December 12, 2013 14:43
Show Gist options
  • Save wannabefro/7928986 to your computer and use it in GitHub Desktop.
Save wannabefro/7928986 to your computer and use it in GitHub Desktop.
CSV.foreach(file,
headers: true,
converters: lambda{|s| s.gsub(',','').to_i ? s && s[0] =~ /\d/ : s}) do |row|
TownHealthRecords.find_or_initialize_by(geography: row['geography']) do |thr|
thr.population = row['population']
save!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment