Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Mon Jul 23 12:40:44 2018
- @author: dipie
- """
- import csv, heapq
- def getname(wcaid):
- with open('WCAdbNEW\WCA_export_Persons.tsv', encoding="utf8") as tsvfile:
- reader = csv.reader(tsvfile, delimiter='\t')
- for row in reader:
- if(row[0] == wcaid):
- return str(row[2])
- def getsingle(event,wcaid):
- with open('WCAdbNEW\WCA_export_RanksSingle.tsv', encoding="utf8") as tsvfile:
- reader = csv.reader(tsvfile, delimiter='\t')
- for row in reader:
- if(row[1] == event and row[0] == wcaid):
- return str(row[2])
- wcaids = []
- threeavg = []
- def getdataevent(event):
- global wcaids
- global threeavg
- global zipthree
- wcaids = []
- threeavg = []
- #zipthree = []
- with open('WCAdbNEW\WCA_export_RanksSingle.tsv', encoding="utf8") as tsvfile:
- reader = csv.reader(tsvfile, delimiter='\t')
- for row in reader:
- if(row[0] != "personId" and row[1] == event):
- wcaids.append(row[0])
- if(row[1] == event):
- threeavg.append(int(row[2]))
- zipthree = list(zip(wcaids,threeavg))
- return zipthree
- newlistclone = []
- def taketopten():
- global newlist,newlistclone
- newlistclone = newlist
- fourbld = getdataevent("444bf")
- fivebld = getdataevent("555bf")
- newlist = []
- for each in fourbld:
- for eachother in fivebld:
- if(each[0] == eachother[0]):
- newlist.append([each[0],
- each[1],
- eachother[1],
- (int(each[1])/int(eachother[1]))]) //change this to eachother[1] - each[1] for second stat
- ratios = []
- for each in newlist:
- ratios.append(each[3])
- largestratios = heapq.nlargest(10,ratios) //and change nlargest to nsmallest for second stat
- index = 0
- while(index < 10):
- for each in newlist:
- if(each[3] == largestratios[index]):
- print(getname(each[0]) + " " + str(each[1]) + " " +
- str(each[2]) + " (" + str(each[3]) + ")")
- index = index+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement