Election results in the London Borough of Sutton.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

postcode-import.rb 733 B

1234567891011121314151617181920212223242526272829303132
  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