Skip to content
Snippets Groups Projects
Commit 26e01d39 authored by Luc Giffon's avatar Luc Giffon
Browse files

add file id to the csv file

parent 0f71126c
Branches
No related tags found
No related merge requests found
......@@ -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("")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment