Created
February 28, 2014 12:30
-
-
Save Olefine/9270261 to your computer and use it in GitHub Desktop.
merging files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pry-debugger' | |
output = File.new("output.txt", 'a') | |
nm1 = File.open("names.txt", 'r') | |
nm2 = File.open("names2.txt", "r") | |
#binding.pry | |
nm1.each_line do |n1| | |
nm2.each_line do |n2| | |
case n1 <=> n2 | |
when -1 then output.write n1; output.write n2 | |
when 0 then output.write n1 | |
when 1 then output.write n2; output.write n1 | |
end | |
break | |
end | |
end | |
output.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment