Created
June 5, 2013 14:53
-
-
Save meeuw/5714460 to your computer and use it in GitHub Desktop.
called like: python removesorted.py haystack needles, only works on sorted files, remove needles from haystack.
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
import sys | |
haystack = open(sys.argv[1]) | |
needles = open(sys.argv[2]) | |
needle = needles.readline()[:-1] | |
counter = 0 | |
while 1: | |
hay = haystack.readline()[:-1] | |
if not hay: break | |
if hay == needle: | |
needle = needles.readline()[:-1] | |
counter = 0 | |
else: | |
print hay | |
counter += 1 | |
if counter > 100: | |
print counter, needle | |
break | |
haystack.close() | |
needles.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment