blob: fcbfe32fc3fe187cbf590f98b4396237f4acc54a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!python
import operator
def read_text(fn):
with open(fn, 'r') as f:
lines = f.readlines()
lookup = {}
for line in lines:
line = line.strip()
total, fn = line.split(' ')
lookup[fn] = int(total)
return lookup
new = read_text('new2.txt')
old = read_text('new.txt')
compare = {}
for key in sorted(new.keys()):
if key in old:
diff = new[key] - old[key]
compare[key] = diff
sorted_compare = sorted(compare.items(), key=operator.itemgetter(1))
for key, diff in sorted_compare:
print("{}\t{}".format(diff, key))
|