Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
elixir
metadata-tools
Commits
0fecc920
Commit
0fecc920
authored
Mar 17, 2021
by
Vilem Ded
Browse files
updates on export command
parent
a0077f6c
Changes
1
Show whitespace changes
Inline
Side-by-side
metadata_tools/commands/export_xls_to_json.py
View file @
0fecc920
...
@@ -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
:
try
:
dataset_dict
=
exporter
.
export_submission
(
fname
)
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
}
'
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment