"""Parse PDF that contains triathlon race result"""

import sys
import re
import codecs


def main():
    # TODO: use argparse
    fin = open(sys.argv[1], encoding='utf8')
    for line in fin:

        # TODO:DOING parse
        pattern = r'\d+ (\d+).*?\d:\d{2}:\d{2} (\d:\d{2}:\d{2}) \d+ (\d:\d{2}:\d{2}) \d+ \d:\d{2}:\d{2} \d+ (\d:\d{2}:\d{2}) \d+(\S+)'
        m = re.match(pattern, line)
        if m is None:
            continue
        aid, swim_str, bike_str, run_str, div = m.groups()

        # TODO: print
        pass

    # TODO: analyze and visualize


if __name__ == '__main__':
    main()

@@ -81,16 +81,47 @@
  codecs%0A
+from datetime import timedelta%0A
 %0A%0Adef ma
@@ -237,18 +237,17 @@
 ODO:
-DOING pars
+ fix styl
 e%0A  
@@ -530,69 +530,483 @@
     
-# TODO: print%0A        pass%0A%0A    # TODO: analyze and visualize
+swim_lap = parse_lap(swim_str)%0A        bike_lap = parse_lap(bike_str)%0A        run_lap = parse_lap(run_str)%0A%0A        print(aid, swim_lap, bike_lap, run_lap, div)%0A%0A    # TODO: analyze and visualize%0A%0A%0Adef parse_lap(lap_str):%0A    %22%22%22Parse string H:MM:SS and return timedelta%22%22%22%0A    pattern = r'(%5Cd):(%5Cd%7B2%7D):(%5Cd%7B2%7D)'%0A    hours, minutes, seconds = map(int, re.match(pattern, lap_str).groups())%0A    result = timedelta(hours=hours, minutes=minutes, seconds=seconds)%0A    return result
 %0A%0A%0Ai

Add parsing lap times