From ca18c187d8137466306cc7a0471964f9bba3caeb Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Thu, 9 Jul 2020 14:01:29 +0200 Subject: [PATCH] [bin][extractlinedata] Small improvements * Make make dir of output dir more consise and handle " " case * simplify verbose output --- bin/postprocessing/extractlinedata.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/bin/postprocessing/extractlinedata.py b/bin/postprocessing/extractlinedata.py index 51dc861925..0347cb736f 100644 --- a/bin/postprocessing/extractlinedata.py +++ b/bin/postprocessing/extractlinedata.py @@ -24,8 +24,8 @@ except: # import locations outDirectory = args['outputDirectory'] -if not outDirectory == '' and not os.path.exists(outDirectory): - os.makedirs(outDirectory) +if outDirectory.strip(): + os.makedirs(outDirectory, exist_ok=True) # loop over all vtk files counter = 0 @@ -68,11 +68,8 @@ for curFile in args['files']: # print the parameters and the column numbers if args['verbosity'] == 2: - with open(csvFileName) as f: + with open(csvFileName) as csvFile: print(csvFileName) - reader = csv.reader(f) - paramList = list(reader) - paramCounter=1 - for param in paramList[0]: - print("%-2i %s" % (paramCounter, param)) - paramCounter += 1 + paramList = list(csv.reader(csvFile))[0] + for i, param in enumerate(paramList): + print("{:>5} {}".format(i+1, param)) -- GitLab