#!/usr/bin/env python import sys, os, re, glob, collections DIR = sys.argv[1] RESULTS = {} for x in os.listdir(DIR): if x.startswith("."): continue n = int(x.split("-")[-1]) f = file(os.path.join(DIR,x)) r = 0 for l in f: if "excluding" in l: r = float(l.split()[2]) if n not in RESULTS: RESULTS[n] = [] RESULTS[n].append(r) for k,v in sorted(RESULTS.items()): med = sorted(v)[1] print k, med