Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def func2(tup):
- return tup[1]
- def func1(tup):
- return tup[0]
- fin = open('input.csv', 'r', encoding='utf8')
- fout = open('output8.txt', 'w', encoding='utf8')
- val = {}
- cnt = list()
- for line in fin:
- s = line.split(';')
- if s[0] in val:
- val[s[0]].append(int(s[1]))
- else:
- val[s[0]] = list()
- val[s[0]].append(int(s[1]))
- for i in val:
- cnt.append((i, sum(val[i]) / len(val[i])))
- cnt = sorted(cnt, key=func1)
- cnt = sorted(cnt, key=func2)
- for j in range(len(cnt)):
- print(cnt[j][0])
- fin.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement