Created
December 5, 2013 08:49
-
-
Save airekans/7802133 to your computer and use it in GitHub Desktop.
Get the diff of the two sorted sequence stored in files.
This file contains hidden or 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
import sys | |
if __name__ == '__main__': | |
file1, file2 = sys.argv[1:] | |
file1_fd = open(file1) | |
file2_fd = open(file2) | |
line1 = file1_fd.readline() | |
line2 = file2_fd.readline() | |
while line1 and line2: | |
if line1 == line2: | |
line1 = file1_fd.readline() | |
line2 = file2_fd.readline() | |
elif line1 < line2: | |
print line1.strip() | |
line1 = file1_fd.readline() | |
else: | |
print line2.strip() | |
line2 = file2_fd.readline() | |
while line1: | |
print line1.strip() | |
line1 = file1_fd.readline() | |
while line2: | |
print line2.strip() | |
line2 = file2_fd.readline() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment