Election results in the London Borough of Sutton.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

import-2014-local.rb 807 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # load 2014 council results
  2. require './models'
  3. require 'csv'
  4. require 'pp'
  5. DataMapper::Model.raise_on_save_failure = true
  6. @found = 0
  7. CSV.foreach(ARGV.shift, :headers => true) do |row|
  8. begin
  9. if @candidate = Candidate.first(:forenames => row['Forenames'], :surname => row['Surname'])
  10. @found += 1
  11. @ccy = @candidate.candidacies.last
  12. if @ccy.election_id == 8
  13. @ccy.votes = row['Votes']
  14. @ccy.save
  15. end
  16. # pp @ccy
  17. end
  18. # pp @candidate
  19. # @p = PollingStation.create(
  20. # :id => row['District'].strip,
  21. # :easting => row['Eastings'],
  22. # :northing => row['Northings'],
  23. # :lat => row['lat'],
  24. # :lng => row['lng']
  25. # )
  26. # @p.save
  27. rescue
  28. pp @p
  29. # puts p.errors
  30. end
  31. end
  32. puts @found