Commit 0fecc920 authored by Vilem Ded's avatar Vilem Ded
Browse files

updates on export command

parent a0077f6c
...@@ -38,17 +38,30 @@ fileList = [] ...@@ -38,17 +38,30 @@ fileList = []
if args.dirname: if args.dirname:
dirname = args.dirname dirname = args.dirname
for f in os.listdir(dirname): for f in os.listdir(dirname):
if os.path.isfile(f): filename = os.path.join(dirname, f)
fileList += os.path.join(dirname, f) if os.path.isfile(filename):
fileList.append(filename)
if args.file: if args.file:
fileList += args.file for f in args.file:
if os.path.isfile(f):
fileList.append(f)
else:
print(f"'{f}' is not file - skipping")
exporter = DishXlsExporter()
exporter = DishXlsExporter()
counter = 0
for fname in fileList: for fname in fileList:
dataset_dict = exporter.export_submission(fname) try:
dataset_dict = exporter.export_submission(fname)
except Exception as e:
raise Exception(f'Error occured in file {fname}') from e
fname_json = pathlib.Path(fname).stem + ".json" fname_json = pathlib.Path(fname).stem + ".json"
fname_out = os.path.join(args.output_dir, fname_json) fname_out = os.path.join(args.output_dir, fname_json)
with open(fname_out, 'w') as outfile: with open(fname_out, 'w') as outfile:
save_exported_datasets_to_file(dataset_dict, outfile) save_exported_datasets_to_file(dataset_dict, outfile)
counter += 1
print(f'File export successful: {counter} files exported to {args.output_dir}')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment