Skip to content

Instantly share code, notes, and snippets.

@jordanyeo
Created March 3, 2016 20:56
Show Gist options
  • Select an option

  • Save jordanyeo/3963f6cbbd20f28316d4 to your computer and use it in GitHub Desktop.

Select an option

Save jordanyeo/3963f6cbbd20f28316d4 to your computer and use it in GitHub Desktop.
require 'csv'
require 'byebug'
source = CSV.read("source.csv")
members = CSV.read("members.csv")
newcsv = CSV.open('result.csv', 'wb')
found = 0
members.each do |member|
member_name = "#{member[8].downcase.strip if member[8]} #{member[9].downcase.strip if member[9]}"
result = source.detect {|acctname, acctype, account, name| (name.downcase.strip if name) == member_name}
if !result
result = source.detect {|acctname, acctype, account, name| (acctname.downcase.strip if acctname) == member_name}
end
if result
member[0] = result[2]
found += 1
end
newcsv << member
end
newcsv.close
puts "Found: #{found}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment