Skip to content
Snippets Groups Projects
Commit 0d3bcac9 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[bin][extractlinedata] do not overwrite previous .csv files

When multiple vtk files were given as arguments to the script together
with a base name for the output .csv files, a single csv file was
created that contained the data of the last given vtk file. This commit
adds an index to the file names in case multiple vtk files are provided.
parent f3084a31
No related branches found
No related tags found
1 merge request!2207Feature/improve extract line data
...@@ -28,7 +28,7 @@ if not outDirectory == '' and not os.path.exists(outDirectory): ...@@ -28,7 +28,7 @@ if not outDirectory == '' and not os.path.exists(outDirectory):
os.makedirs(outDirectory) os.makedirs(outDirectory)
# loop over all vtk files # loop over all vtk files
counter = 1 counter = 0
for curFile in args['files']: for curFile in args['files']:
# if no output directory was specified, use the directory of the given file # if no output directory was specified, use the directory of the given file
...@@ -39,13 +39,15 @@ for curFile in args['files']: ...@@ -39,13 +39,15 @@ for curFile in args['files']:
# if no basename was specified, reuse the file name for the .csv file # if no basename was specified, reuse the file name for the .csv file
if args['outFile'] == '': if args['outFile'] == '':
csvFileName = os.path.join(curOutDirectory, os.path.splitext(os.path.basename(curFile))[0] + ".csv") csvFileName = os.path.join(curOutDirectory, os.path.splitext(os.path.basename(curFile))[0] + ".csv")
elif len(args['files']) > 1:
csvFileName = os.path.join(curOutDirectory, args['outFile'] + "_" + str(counter) + ".csv")
else: else:
csvFileName = os.path.join(curOutDirectory, args['outFile'] + ".csv") csvFileName = os.path.join(curOutDirectory, args['outFile'] + ".csv")
counter += 1
# print progress to command line # print progress to command line
if args['verbosity'] == 1: if args['verbosity'] == 1:
print("Processing file ({}/{}): {}".format(counter, len(args['files']), os.path.basename(curFile))) print("Processing file ({}/{}): {}".format(counter, len(args['files']), os.path.basename(curFile)))
counter += 1
# load vtk file # load vtk file
if os.path.splitext(curFile)[1] == ".vtp": if os.path.splitext(curFile)[1] == ".vtp":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment