Example #1
0
def check_bishophill():
    f = os.path.join('results','676.csv')
    for items in read_results_file(f):
        print '\t'.join(map(str, items))

    data = process_results_file(f)
    print calc_race_times(data)
Example #2
0
def list_clubs():
    folder = 'results'
    clubs = set()
    for f in os.listdir(folder):
        fpath = os.path.join(folder, f)
        for _, club, _, _ in read_results_file(fpath):
            clubs.add(normalise_club1(club))

    print '\n'.join(sorted(clubs))
def print_all_clubs():
    clubs = set()
    result_folder = 'results'
    for f in os.listdir(result_folder):
        fpath = os.path.join(result_folder, f)
        for name, club, category, time in read_results_file(fpath):
            clubs.add(club)

    print '\n'.join(sorted(clubs))
Example #4
0
    def process(self):
        """
        Munges a results csv file and returns usable data

        Returns:
            Dict[str, int]: mapping of runner name -> finish time (in seconds)
        """
        runners = {}
        for name, club, category, time in read_results_file(self._f):
            runners[name] = time

        if not runners:
            raise EmptyResultSet

        return runners
def find_ambiguous_names():
    runner_clubs = defaultdict(set)

    result_folder = 'results'
    fname = 'result_to_race_index.dat'
    result_to_race, _ = read_result_to_race_index(fname)
    for race_id in result_to_race:
        f = os.path.join(result_folder, race_id + '.csv')
        if not os.path.exists(f):
            continue
        for name, club, category, time in read_results_file(f):
            runner_clubs[name].add(club)

    ordered_names = sorted(runner_clubs.iteritems(),
                           reverse=True,
                           key=lambda x: len(x[1]))

    lines = []
    for name, clubs in ordered_names[0:10]:
        lines.append('%s\t%s' % (name, ', '.join(clubs)))
    print '\n'.join(lines)