# 10left.py # # script originally written to see how many reviews there were before we hit 10 total public reviews for each IFComp entry # # it was expanded to look at public *or* private and also set a different goal # # external files: # 10left.txt is created by highlighting columns a-d and cutting and pasting. It should have tab-separated values. # import sys from collections import defaultdict # default values goal = 10 all_entries = True #tracking variables left = defaultdict(list) totals = 0 entries = 0 cmd_count = 1 while cmd_count < len(sys.argv): arg = sys.argv[cmd_count] if arg.isdigit(): goal = int(sys.argv[1]) elif arg == 'a': all_entries = True elif arg == 'p': all_entries = False cmd_count += 1 review_countcolumn = 2 if all_entries else 3 with open("10left.txt") as file: for line in file: l = line.strip().split('\t') try: x = int(l[review_countcolumn]) except: print("No number in line {}", l[0]) continue if x >= goal: continue totals = totals + (goal - x) left[goal-x].append(l[0]) print(l[0], goal - x) entries += 1 print(totals, "reviews away from {} average total".format(goal)) print(entries, "entries total") for l in sorted(left): print('{} has {}:'.format(l, len(left[l])), ' / '.join(sorted(left[l])))