output_analysis now takes multiple files and not just a single directory as argument for the analysis input (close #36).

This commit is contained in:
antux18 2024-08-05 17:19:45 +02:00
parent cd9a9000d5
commit ab72ee398c

View File

@ -146,8 +146,9 @@ def main():
description = "This script analyzes the outputs from ECG to create " \ description = "This script analyzes the outputs from ECG to create " \
"tables." "tables."
) )
parser.add_argument('-v', '--verbose', parser.add_argument(
action = 'store_true', "-v", "--verbose",
action = "store_true",
help = "Shows more details on what is being done." help = "Shows more details on what is being done."
) )
parser.add_argument( parser.add_argument(
@ -157,25 +158,30 @@ def main():
required = True required = True
) )
parser.add_argument( parser.add_argument(
"input_dir", "-i", "--input",
help = "Path to the directory where the CSV files used as input for " \ action = "append",
"the analysis function are stored. They must be all outputs from ECG." help = "The CSV file used as input for the analysis function." \
"Multiple files can be specified by repeating this argument" \
"with different paths. All the input files must be outputs" \
"from ECG.",
required = True
) )
parser.add_argument( parser.add_argument(
"output_path", "-o", "--output",
help = "Path to the output CSV file that will be created by the " \ help = "Path to the output CSV file that will be created by the " \
"analysis function." "analysis function.",
required = True
) )
args = parser.parse_args() args = parser.parse_args()
analysis_type = args.analysis_type analysis_type = args.analysis_type
input_dir = args.input_dir input_paths = args.input
output_path = args.output_path output_path = args.output
# Parsing the inputs from the directory: # Parsing the input files:
input_tables = [] input_tables = []
for input_path in os.listdir(input_dir): for path in input_paths:
input_file = open(os.path.join(input_dir, input_path)) input_file = open(path)
input_tables.append(list(csv.reader(input_file))) input_tables.append(list(csv.reader(input_file)))
input_file.close() input_file.close()