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.
 
 
 
 

41 lines
807 B

  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