From 26e01d391259f27d266ed6973b3d58eef70175c7 Mon Sep 17 00:00:00 2001 From: Luc Giffon <luc.giffon@lis-lab.fr> Date: Thu, 22 Nov 2018 16:28:43 +0100 Subject: [PATCH] add file id to the csv file --- skluc/main/tools/experiences/gather_results.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/skluc/main/tools/experiences/gather_results.py b/skluc/main/tools/experiences/gather_results.py index 23bfc56..3516cdc 100644 --- a/skluc/main/tools/experiences/gather_results.py +++ b/skluc/main/tools/experiences/gather_results.py @@ -25,7 +25,7 @@ from skluc.main.utils import logger if __name__ == '__main__': arguments = docopt.docopt(__doc__) - pattern_to_recognize = arguments["--patern"] + pattern_to_recognize = arguments["--patern"] #.+\_stdout.txt mypath = os.path.abspath(arguments["--input-dir"]) res_walk = walk(mypath) onlyfiles = [] @@ -35,18 +35,21 @@ if __name__ == '__main__': results = [] compiled_re = re.compile(pattern_to_recognize) first_line = "" + pattern_file_id = r".+\d+job_(\d+)\.\d+_.+" + compiled_re_file_id = re.compile(pattern_file_id) for f_name in onlyfiles: if compiled_re.match(f_name) is None: continue + file_id = compiled_re_file_id.match(f_name).group(1) with open(f_name, "r") as f: lines = f.readlines() try: if not first_line and arguments["--header"]: - first_line = lines[0].strip() + first_line = lines[0].strip() + ",file_timestamp" if arguments["--header"]: - results.append(lines[1].strip()) + results.append(lines[1].strip() + "," + file_id) else: - results.append(lines[0].strip()) + results.append(lines[0].strip() + "," + file_id) except IndexError: results.append("") -- GitLab