Skip to content

Instantly share code, notes, and snippets.

@pezholio
Created January 27, 2015 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pezholio/61ed2547c01daa7c0310 to your computer and use it in GitHub Desktop.
Save pezholio/61ed2547c01daa7c0310 to your computer and use it in GitHub Desktop.
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