s460929-mlworkshops/script.py
2020-04-10 15:18:37 +02:00

25 lines
719 B
Python

import csv
file = open("wer.txt", "r")
scores = []
for f in file:
if "Scores" in f:
score = (f[22:].rstrip("\n").split(" "))
score = (int(score[1])+int(score[2])+int(score[3]))/(int(score[0])+int(score[1])+int(score[2]))
scores.append(round(score,2))
file.close()
with open('wikiniews_results.tsv','r') as f_in:
with open('newresults.tsv', 'w') as f_out:
writer = csv.writer(f_out, delimiter=' ', lineterminator='\n')
reader = csv.reader(f_in, delimiter='\t')
result = []
for row,score in zip(reader, scores):
# add new column values
row.append('\t'+str(score))
result.append(row)
writer.writerows(result)