from typing import TextIO from dataclasses import asdict, fields from evaluation.T import QueryRow SEP = ',' def write_head(f: TextIO, row_class: QueryRow): head = SEP.join([field.name for field in fields(row_class)]) f.write(head + '\n') def write_row(f: TextIO, row: QueryRow): f.write(SEP.join([str(i) for i in asdict(row).values()]) + "\n")