Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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