Advertisement
Guest User

Fabio De'Rose weird BLD times :P

a guest
Jul 23rd, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.11 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. def getsingle(event,wcaid):
  18.     with open('WCAdbNEW\WCA_export_RanksSingle.tsv', encoding="utf8") as tsvfile:
  19.         reader = csv.reader(tsvfile, delimiter='\t')
  20.         for row in reader:
  21.             if(row[1] == event and row[0] == wcaid):
  22.                 return str(row[2])
  23.  
  24. wcaids = []
  25. threeavg = []
  26. def getdataevent(event):
  27.     global wcaids
  28.     global threeavg
  29.     global zipthree
  30.     wcaids = []
  31.     threeavg = []
  32.     #zipthree = []
  33.     with open('WCAdbNEW\WCA_export_RanksSingle.tsv', encoding="utf8") as tsvfile:
  34.         reader = csv.reader(tsvfile, delimiter='\t')
  35.         for row in reader:
  36.             if(row[0] != "personId" and row[1] == event):
  37.                 wcaids.append(row[0])
  38.             if(row[1] == event):
  39.                 threeavg.append(int(row[2]))
  40.     zipthree = list(zip(wcaids,threeavg))
  41.     return zipthree
  42.  
  43. newlistclone = []
  44. def taketopten():
  45.     global newlist,newlistclone
  46.     newlistclone = newlist
  47.    
  48.  
  49. fourbld = getdataevent("444bf")
  50. fivebld = getdataevent("555bf")
  51. newlist = []
  52. for each in fourbld:
  53.     for eachother in fivebld:
  54.         if(each[0] == eachother[0]):
  55.             newlist.append([each[0],
  56.                             each[1],
  57.                             eachother[1],
  58.                             (int(each[1])/int(eachother[1]))]) //change this to eachother[1] - each[1] for second stat
  59.  
  60. ratios = []
  61. for each in newlist:
  62.     ratios.append(each[3])
  63. largestratios = heapq.nlargest(10,ratios) //and change nlargest to nsmallest for second stat
  64. index = 0
  65. while(index < 10):
  66.     for each in newlist:
  67.         if(each[3] == largestratios[index]):
  68.             print(getname(each[0]) + " " + str(each[1]) + " " +
  69.                   str(each[2]) + " (" + str(each[3]) + ")")
  70.     index = index+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement