import re WTF = re.compile(r".*: (\d+),.*dataset/(\d+).txt") by_size = dict() with open("stdout.txt") as f: while True: line1 = f.readline().strip() if not line1: break m = WTF.match(line1) processors = int(m.group(1)) size = int(m.group(2)) if size not in by_size: by_size[size] = dict() line2 = f.readline().strip() line3 = f.readline().strip() time2 = line2.split(": ")[1] time5 = line3.split(": ")[1] if processors not in by_size[size]: by_size[size][processors] = (time2, time5) print("#table(") print(" columns: (auto, auto, auto, auto, auto, auto),") columns = [1, 2, 4, 8, 16] print(" [], ", ", ".join(map(lambda c: f"[{c}]", columns)), ",") for size, entries in sorted(by_size.items()): print(f" [{size}],") for processors, (time2, time5) in sorted(entries.items()): print(f" [{time2} #linebreak() {time5}],", end = None) print() print(")")