SHARE
TWEET

Untitled

a guest Jan 19th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a = dict.fromkeys(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11'], [])
  2. with open('dataset_3380_5.txt', 'r+') as file:
  3.     while True:
  4.         lst = [file.readline().split("\t")[:-2]]
  5.         if lst == []:
  6.             break
  7.         a[lst[0]] += (int(lst[-1]))
  8.     for key in a:
  9.         file.write(key + ' ')
  10.         if a[key]:
  11.             file.write(str(sum(a[key])/len(a[key])) + '\n')
  12.         else:
  13.             file.write('-')
  14.         file.write('\n')
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