Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- first_hash = Hash.new
- second_hash = Hash.new
- first = File.open('first.txt', 'r')
- second = File.open('second.txt', 'r')
- first.each do |line|
- line = line.split(/\t/)
- supID = line[0]
- contID = line[1]
- cbsa = line[2]
- ctgy = line[3]
- first_hash["#{contID}|""#{cbsa}|""#{ctgy}"] ||= []
- first_hash["#{contID}|""#{cbsa}|""#{ctgy}"] << "#{supID}"
- end
- first_hash.each do |key, value|
- key = key.split("|")
- contID = key[0]
- cbsa = key[1]
- ctgy = key[2]
- second.each do |line|
- line = line.split(/\t/)
- contID = line[0]
- cbsa = line[1]
- ctgy = line[2]
- mftr = line[3]
- model = line[4].strip
- value.each do |item|
- second_hash["#{contID}|""#{cbsa}|""#{ctgy}|""#{item}"] ||= []
- second_hash["#{contID}|""#{cbsa}|""#{ctgy}|""#{item}"] << "#{model}"
- end
- end
- end
- puts second_hash
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement