One way
#! /usr/bin/env python3 import csv import os from tabulate import tabulate with open('summary.csv', 'w') as file: writer = csv.writer(file) writer.writerow(['SCENARIO', 'STATUS']) files = os.listdir('input_folder') for file in files: with open(f'input_folder/{file}', 'r') as csv_file: read_file = csv.reader(csv_file) for line in read_file: with open('summary.csv', 'a') as summary: if line[1] == ' ': status = 'FAIL' else: status = 'PASS' writer = csv.writer(summary) writer.writerow([f'input_folder/{file}', status]) with open('summary.csv', 'r') as file: read_file = csv.reader(file) print(tabulate(read_file, headers='firstrow'))
Output:SCENARIO STATUS
----------------------- --------
input_folder/file_1.csv PASS
input_folder/file_1.csv PASS
input_folder/file_1.csv PASS
input_folder/file_2.csv PASS
input_folder/file_2.csv FAIL
input_folder/file_2.csv PASS
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags