<reponame>jonesmartins/ppd
import os
import sys
from collections import namedtuple

arquivos = os.listdir('.')
Perf = namedtuple('Perf', ['np', 'n', 't'])
perfs = []

for arquivo in arquivos:
    if arquivo.split('.')[-1] != 'txt':
        continue
    split = arquivo.split('_')
    np = int(split[1])
    n = int(split[3])
    with open(arquivo, 'r') as f:
        t = float(f.readline())
    new_perf = Perf(np=np, n=n, t=t)
    perfs.append(new_perf)

perfs = sorted(perfs, key=lambda x: (x.n, x.np))

try:
    with open('log.txt', 'w') as logfile:
        form = 'NP: {:3} N: {:10} T: {:10}\n'
        forms = [form.format(perf.np, perf.n, perf.t) for perf in perfs]
        logfile.writelines(forms)
        print(forms)
except ValueError:
    os.remove('log.txt')
        


import os
import sys
from collections import namedtuple

arquivos = os.listdir('.')
Perf = namedtuple('Perf', ['np', 'n', 't'])
perfs = []

for arquivo in arquivos:
    if arquivo.split('.')[-1] != 'txt':
        continue
    split = arquivo.split('_')
    np = int(split[1])
    n = int(split[3])
    with open(arquivo, 'r') as f:
        t = float(f.readline())
    new_perf = Perf(np=np, n=n, t=t)
    perfs.append(new_perf)

perfs = sorted(perfs, key=lambda x: (x.n, x.np))

try:
    with open('log.txt', 'w') as logfile:
        form = 'NP: {:3} N: {:10} T: {:10}\n'
        forms = [form.format(perf.np, perf.n, perf.t) for perf in perfs]
        logfile.writelines(forms)
        print(forms)
except ValueError:
    os.remove('log.txt')