SHARE
TWEET

Untitled

a guest Oct 21st, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top