from glob import glob iteracje = 0 for plik in glob('scores/model.iter*.npz.bleu'): with open(plik,'r') as otwarty_plik: fl = otwarty_plik.readline() current_bleu = float(fl[fl.find("=")+1:fl.find(",")]) if iteracje == 0: max_bleu = current_bleu max_bleu_file = plik else: if current_bleu > max_bleu: max_bleu = current_bleu max_bleu_file = plik iteracje += 1 otwarty_plik.close() print(max_bleu_file)