I have a folder lets say as 'input_Folder' which has a list of CSV files with data. I'm trying to write a python code which reads this list of CSV files from the input_folder and creates a master CSV file with two columns.
The columns in the master CSV files are 'Scenario' and 'Status'
Column Name requirement are as follows,
Scenario = Name of the file from the directory and
Status = if the file has a value in the second row of second column then populate as 'Pass' else 'Fail'
Below is my code. After executing the code i'm able to see Master CSV created but with empty lines. I'm quite new to python so could somebody help me out here please
import os
import csv
path = (Input file path)
with open(SUMMARY.csv", 'w') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['SCENARIO', 'STATUS'])
for files in os.walk(path):
for filename in files:
with open(input_file.csv") as csv_file: #checking if the code is working for
#one sample file
all_rows = list(csv_file)
line_count = 0
for row in all_rows[1:2]:
if line_count == 1:
if row[1].value == none:
writer.writerow([os.path.basename(filename).split(".")
[0],'PASS'])
else:
writer.writerow([os.path.basename(filename).split(".")
[0],'FAIL'])
line_count += 1
The columns in the master CSV files are 'Scenario' and 'Status'
Column Name requirement are as follows,
Scenario = Name of the file from the directory and
Status = if the file has a value in the second row of second column then populate as 'Pass' else 'Fail'
Below is my code. After executing the code i'm able to see Master CSV created but with empty lines. I'm quite new to python so could somebody help me out here please
import os
import csv
path = (Input file path)
with open(SUMMARY.csv", 'w') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(['SCENARIO', 'STATUS'])
for files in os.walk(path):
for filename in files:
with open(input_file.csv") as csv_file: #checking if the code is working for
#one sample file
all_rows = list(csv_file)
line_count = 0
for row in all_rows[1:2]:
if line_count == 1:
if row[1].value == none:
writer.writerow([os.path.basename(filename).split(".")
[0],'PASS'])
else:
writer.writerow([os.path.basename(filename).split(".")
[0],'FAIL'])
line_count += 1
Larz60+ write Feb-13-2022, 08:33 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
2nd Notice. Please use BBcode tags.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
2nd Notice. Please use BBcode tags.