Skip to content

Instantly share code, notes, and snippets.

@klochner
Created September 30, 2011 23:16
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 klochner/1255283 to your computer and use it in GitHub Desktop.
Save klochner/1255283 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
leads = File.read('archstone_leads.csv').lines.collect {|x| x.strip}
closed = File.read('archstone_closed.csv').lines.collect {|x| x.strip}
leads_by_name_hash = []
leads_by_email_hash = []
sources = []
closes_by_name_hash = []
closes_by_email_hash = []
out = "CommunityName,Name,Email,Source,Closed\n"
leads.each_with_index do |lead, index|
#puts index
lead = lead.split(',')
leads_by_name_hash << {:community => lead[2], :name => "#{lead[4]}#{lead[5]}".strip}
leads_by_email_hash << {:community => lead[2], :email => lead[3]}
sources << lead[7]
end
closed.each_with_index do |close, index|
#puts index
close = close.split(',')
closes_by_name_hash << {:community => close[4], :name => "#{close[1]}#{close[2]}".strip}
closes_by_email_hash << {:community => close[4], :email => close[0]}
end
leads_by_email_hash.each_with_index do |hash, index|
#puts index
by_name = leads_by_name_hash[index]
if closes_by_email_hash.include?(hash)
#puts 'true'
out += "#{hash[:community]},#{by_name[:name]},#{hash[:email]},#{sources[index]},X\n"
elsif closes_by_name_hash.include?(by_name)
#puts 'true'
out += "#{hash[:community]},#{by_name[:name]},#{hash[:email]},#{sources[index]},X\n"
end
end
puts out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment