I want to compare two test file in python.(actually they are windows registry files(.reg) but they are all text). im looking for all the differences between two files and not just the first line which is not the same of second file. thanks in advance
f1 = open(filepath1)
f2 = open(filepath2)
lines = f2.readlines()
for i,line in enumerate(f1):
if line != lines[i]:
print "line", i, "is different:"
print '\t', line
print '\t', lines[i]
print "\t differences in positions:", ', '.join(map(str, [c for c in range(len(line)) if line[c]!= lines[i][c]]))
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With