Don't just read the files line by line but filter each line: extract the stuff within (
)
and remove BlockNum:
if it exists. Something like this:
def getRecords(fn):
for line in open(fn, 'r'):
entry = line.rstrip()[line.find('(')+1:-1]
if entry.startswith('BlockNum:'):
yield entry[10:]
else:
yield entry
import itertools
filesAreEqual = all(a == b for a, b in itertools.izip(getRecords("file1.txt"),
getRecords("file2.txt")))