Election results in the London Borough of Sutton.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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