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.
 
 
 
 

33 line
733 B

  1. # Import postcode data from CodePoint Open
  2. require 'csv'
  3. require_relative "../app"
  4. i = 0
  5. CSV.foreach(ARGV.shift) do |row|
  6. i += 1
  7. next if i == 1 # skip header row
  8. puts i
  9. puts row
  10. puts
  11. ward = District.first(:ons_district_code => row[9])
  12. puts Postcode.create!(
  13. :postcode => row[0],
  14. :positional_quality_indicator => row[1],
  15. :eastings => row[2],
  16. :northings => row[3],
  17. :country_code => row[4],
  18. :nhs_regional_ha_code => row[5],
  19. :nhs_ha_code => row[6],
  20. :admin_county_code => row[7],
  21. :admin_district_code => row[8],
  22. :admin_ward_code => row[9],
  23. :lat => row[10],
  24. :lng => row[11],
  25. :ward_id => ward.id
  26. )
  27. end