Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. def func2(tup):
  2. return tup[1]
  3.  
  4. def func1(tup):
  5. return tup[0]
  6.  
  7. fin = open('input.csv', 'r', encoding='utf8')
  8. fout = open('output8.txt', 'w', encoding='utf8')
  9. val = {}
  10. cnt = list()
  11. for line in fin:
  12. s = line.split(';')
  13. if s[0] in val:
  14. val[s[0]].append(int(s[1]))
  15. else:
  16. val[s[0]] = list()
  17. val[s[0]].append(int(s[1]))
  18. for i in val:
  19. cnt.append((i, sum(val[i]) / len(val[i])))
  20. cnt = sorted(cnt, key=func1)
  21. cnt = sorted(cnt, key=func2)
  22. for j in range(len(cnt)):
  23. print(cnt[j][0])
  24. fin.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement