Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # this program and the extract of the wca export must be in the same folder
- # to run, just type "python program.py"
- import csv
- country_list = []
- event_list = []
- avg_list = []
- def avg(l):
- out = 0.0
- if len(l)==0: return 0.0
- for x in l:
- out += x
- return 1.0*out/len(l)
- count = 0
- discard = 1 # at least 2 competitions per country
- with open('WCA_export_Competitions.tsv','rb') as tsvin:
- tsvin = csv.reader(tsvin, delimiter='\t')
- for line in tsvin:
- count += 1
- if count == 1: continue # :'(
- country = line[3]
- year = line[5]
- if country not in country_list:
- country_list.append(country)
- event_list.append([])
- i = country_list.index(country)
- events = line[10].split()
- event_list[i].append(len(events))
- for x in event_list:
- avg_list.append(avg(x))
- count = 1
- for (x, y, z) in sorted(zip(avg_list, country_list, event_list))[::-1]:
- if (len(z)>discard):
- print "%3s"%count+")", ("%.2f"%x).zfill(5), y
- count += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement