Advertisement
Guest User

Fabio De'Rose weird BLD results :P

a guest
Jul 23rd, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.78 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. """
  3. Created on Mon Jul 23 12:40:44 2018
  4.  
  5. @author: dipie
  6. """
  7.  
  8. import csv, heapq
  9.  
  10. def getname(wcaid):
  11.     with open('WCAdbNEW\WCA_export_Persons.tsv', encoding="utf8") as tsvfile:
  12.         reader = csv.reader(tsvfile, delimiter='\t')
  13.         for row in reader:
  14.             if(row[0] == wcaid):
  15.                 return str(row[2])
  16.            
  17. wcaids = []
  18. threeavg = []
  19. def getdataevent(event):
  20.     global wcaids
  21.     global threeavg
  22.     global zipthree
  23.     wcaids = []
  24.     threeavg = []
  25.     #zipthree = []
  26.     with open('WCAdbNEW\WCA_export_RanksSingle.tsv', encoding="utf8") as tsvfile:
  27.         reader = csv.reader(tsvfile, delimiter='\t')
  28.         for row in reader:
  29.             if(row[0] != "personId" and row[1] == event):
  30.                 wcaids.append(row[0])
  31.             if(row[1] == event):
  32.                 threeavg.append(int(row[2]))
  33.     zipthree = list(zip(wcaids,threeavg))
  34.     return zipthree    
  35.  
  36. fourbld = getdataevent("444bf")
  37. fivebld = getdataevent("555bf")
  38. newlist = []
  39. for each in fourbld:
  40.     for eachother in fivebld:
  41.         if(each[0] == eachother[0]):
  42.             newlist.append([each[0],
  43.                             each[1],
  44.                             eachother[1],
  45.                             (int(each[1])/int(eachother[1]))])
  46.                             #change this to eachother[1] - each[1]
  47.                             #for 2nd stat
  48.  
  49. ratios = []
  50. for each in newlist:
  51.     ratios.append(each[3])
  52. largestratios = heapq.nlargest(10,ratios) #change this to nsmallest for 2nd stat
  53. index = 0
  54. while(index < 10):
  55.     for each in newlist:
  56.         if(each[3] == largestratios[index]):
  57.             print(getname(each[0]) + " " + str(each[1]) + " " +
  58.                   str(each[2]) + "(" + str(each[3]) + ")")
  59.     index = index+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement