Skip to content

Instantly share code, notes, and snippets.

@shiv3

shiv3/solv.rb Secret

Created November 23, 2018 09:28
Show Gist options
  • Save shiv3/8124cabf39bb46b7377c36bad06f6ea3 to your computer and use it in GitHub Desktop.
Save shiv3/8124cabf39bb46b7377c36bad06f6ea3 to your computer and use it in GitHub Desktop.
require 'csv'
csv1 = CSV.read("1.csv")
csv2 = CSV.read("2.csv")
csv3 = CSV.read("3.csv")
csv4 = CSV.read("4.csv")
csv5 = CSV.read("5.csv")
users = {}
csv1.each do |v|
mail = v[0]
job_title = v[1]
income = v[2]
u = {:job_title=>job_title,:income =>income}
users[mail] = u
end
csv2.each do |v|
email = v[0]
state = v[1]
users[email][:state] = state
end
csv4.each do |v|
income = v[0]
state = v[1]
street = v[2]
postal = v[3]
users.select{|k,v| v[:income] == income}.each{|k,v|
v[:state]=state;v[:street]=street;v[:postal]=postal
}
end
csv3.each do |v|
ssn = v[0]
state = v[1]
street = v[2]
users.select{|k,v| v[:state] == state && v[:street] == street }.each{|k,v|v[:ssn]=ssn;v[:street]=street}
end
csv5.each do |v|
first_name = v[0]
street = v[1]
users.select{|k,v| v[:street] == street }.each{|k,v|v[:first_name]=first_name}
end
# p users.select{|k,v| k.downcase.include?(v[:first_name].downcase)}
users.select{|k,v| v[:job_title].include?("Captain") }.each{|k,v|
p k
url = "***"
cmd = "curl -s '#{url}' --data 'first_name=#{v[:first_name]}&last_name=Yakubovics&email=#{k}&ssn=#{v[:ssn]}&street=#{v[:street]}' --compressed"
puts "------------------"
puts cmd
ret = `#{cmd}`
puts ret
exit unless ret.include?("error")
sleep 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment