implementing results csv and local to local

This commit is contained in:
alex
2023-09-06 15:27:26 +02:00
parent 02cfd51fd9
commit afc6c5f3cf
3 changed files with 94 additions and 34 deletions

23
results_tools.py Normal file
View File

@@ -0,0 +1,23 @@
# copyright: Canonical
"Tools for managing results."
import csv
from uuid import uuid4
class Results:
def __init__(self, *args, **kwargs):
self.result_list = [["Run num", "test_case", "files", "MB/s", "time", "full size"]]
def add(self, row: list) -> None:
"""Add a row to the results lists.
Args:
row (list): a row of results.
"""
self.result_list.append(row)
def save_to_csv(self) -> None:
"""Save results to csv file in the current directory."""
with open(f"results{uuid4()}.csv", "w") as f:
cw = csv.writer(f)
cw.writerows(self.result_list)