Election results in the London Borough of Sutton.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

load-polling-districts.rb 489 B

12345678910111213141516171819202122232425
  1. # load polling districts data
  2. require './models'
  3. require 'csv'
  4. require 'pp'
  5. DataMapper::Model.raise_on_save_failure = true
  6. PollingStation.destroy
  7. CSV.foreach(ARGV.shift, :headers => true) do |row|
  8. begin
  9. @p = PollingStation.create(
  10. :id => row['District'].strip,
  11. :easting => row['Eastings'],
  12. :northing => row['Northings'],
  13. :lat => row['lat'],
  14. :lng => row['lng']
  15. )
  16. @p.save
  17. rescue
  18. pp @p
  19. # puts p.errors
  20. end
  21. end