X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=resources%2Ftools%2Fpresentation%2Fnew%2Futils.py;fp=resources%2Ftools%2Fpresentation%2Fnew%2Futils.py;h=a2aa0dc0717a925b685bba71482bf040b20f462e;hb=2d001ed910d3835848fccb7bb96a98a5270698fe;hp=a4e24663b50f17b1a7ed7f9947878dba1098b9e2;hpb=a9f251c649a5dea7428a43dc24380077a72dacba;p=csit.git diff --git a/resources/tools/presentation/new/utils.py b/resources/tools/presentation/new/utils.py index a4e24663b5..a2aa0dc071 100644 --- a/resources/tools/presentation/new/utils.py +++ b/resources/tools/presentation/new/utils.py @@ -17,8 +17,9 @@ import multiprocessing import subprocess import numpy as np -import pandas as pd import logging +import csv +import prettytable from os import walk, makedirs, environ from os.path import join, isdir @@ -253,6 +254,29 @@ def classify_anomalies(data): return classification, avgs +def convert_csv_to_pretty_txt(csv_file, txt_file): + """Convert the given csv table to pretty text table. + + :param csv_file: The path to the input csv file. + :param txt_file: The path to the output pretty text file. + :type csv_file: str + :type txt_file: str + """ + + txt_table = None + with open(csv_file, 'rb') as csv_file: + csv_content = csv.reader(csv_file, delimiter=',', quotechar='"') + for row in csv_content: + if txt_table is None: + txt_table = prettytable.PrettyTable(row) + else: + txt_table.add_row(row) + txt_table.align["Test case"] = "l" + if txt_table: + with open(txt_file, "w") as txt_file: + txt_file.write(str(txt_table)) + + class Worker(multiprocessing.Process): """Worker class used to process tasks in separate parallel processes. """