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.
 
 
 
 

25 regels
469 B

  1. # load polling stations data (polling-stations.csv)
  2. require './models'
  3. require 'csv'
  4. require 'pp'
  5. DataMapper::Model.raise_on_save_failure = true
  6. CSV.foreach(ARGV.shift, :headers => false) do |row|
  7. begin
  8. if @p = PollingStation.get(row[1])
  9. @p.name = row[2]
  10. @p.address = row[3]
  11. @p.postcode = row[4]
  12. @p.save
  13. else
  14. puts "#{row[1]} not found"
  15. end
  16. rescue
  17. puts @p.saved?
  18. pp @p
  19. @p.errors.each { |r| puts r }
  20. end
  21. end