Created
January 27, 2015 17:53
-
-
Save pezholio/61ed2547c01daa7c0310 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'httparty' | |
total = 0 | |
success = 0 | |
failure = 0 | |
CSV.open("responses.csv") do |rows| | |
rows.each do |r| | |
response = HTTParty.post("http://sorting-office.openaddressesuk.org/address", body: { | |
address: r[3], | |
contribute: true | |
}) | |
if response.code == 200 | |
puts "#{r[3]} - Success!" | |
success += 1 | |
else | |
puts "#{r[3]} - Failed :(" | |
failure +=1 | |
end | |
total += 1 | |
sleep 1 | |
end | |
end | |
puts "#{total} addresses processes" | |
puts "#{success} sucessfully imported" | |
puts "#{failure} had problems :(" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment