Election results in the London Borough of Sutton.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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