Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
a504c310
Commit
a504c310
authored
1 year ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
WIP for fill_xlsx.
parent
db54ff43
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!100
WIP: Filling XLSX: Seems to be working.
,
!93
Filling XLSX: Everything except multiple choice.
Pipeline
#48828
failed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
+6
-8
6 additions, 8 deletions
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
with
6 additions
and
8 deletions
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
+
6
−
8
View file @
a504c310
...
@@ -282,7 +282,7 @@ out: union[dict, None]
...
@@ -282,7 +282,7 @@ out: union[dict, None]
if
isinstance
(
content
,
list
):
if
isinstance
(
content
,
list
):
if
not
content
:
# empty list
if
not
content
:
# empty list
continue
continue
#
l
ist elements must be all of the same type.
#
L
ist elements must be all of the same type.
assert
len
(
set
(
type
(
entry
)
for
entry
in
content
))
==
1
assert
len
(
set
(
type
(
entry
)
for
entry
in
content
))
==
1
if
isinstance
(
content
[
0
],
dict
):
# all elements are dicts
if
isinstance
(
content
[
0
],
dict
):
# all elements are dicts
...
@@ -304,24 +304,20 @@ out: union[dict, None]
...
@@ -304,24 +304,20 @@ out: union[dict, None]
content
=
[
content
]
# make list for unified treatment below
content
=
[
content
]
# make list for unified treatment below
# collecting the data
# collecting the data
assert
isinstance
(
content
,
list
)
# TODO do we want this??? make list non-lists?
assert
isinstance
(
content
,
list
)
if
len
(
content
)
==
1
:
value
=
"
;
"
.
join
(
content
)
# TODO we need escaping of values
value
=
content
[
0
]
else
:
value
=
"
;
"
.
join
(
content
)
# TODO we need escaping of values
path_str
=
p2s
(
path
)
path_str
=
p2s
(
path
)
assert
path_str
not
in
insertables
assert
path_str
not
in
insertables
insertables
[
path_str
]
=
value
insertables
[
path_str
]
=
value
if
only_collect_insertables
:
if
only_collect_insertables
:
return
insertables
return
insertables
if
not
current_path
:
#
t
op level returns
(?)
if
not
current_path
:
#
T
op level returns
, because there are only sheets for the children.
return
None
return
None
# actual data insertion
# actual data insertion
insert_row
=
None
insert_row
=
None
sheet
=
None
sheet
=
None
for
path_str
,
value
in
insertables
.
items
():
for
path_str
,
value
in
insertables
.
items
():
sheet_meta
=
self
.
_sheet_index
[
path_str
]
sheet_meta
=
self
.
_sheet_index
[
path_str
]
if
sheet
is
None
:
if
sheet
is
None
:
sheet
=
sheet_meta
.
sheet
sheet
=
sheet_meta
.
sheet
...
@@ -376,6 +372,8 @@ validation_schema: dict, optional
...
@@ -376,6 +372,8 @@ validation_schema: dict, optional
except
ValidationError
as
ve
:
except
ValidationError
as
ve
:
print
(
ve
.
message
)
print
(
ve
.
message
)
raise
RuntimeError
(
"
Validation failed
"
)
raise
RuntimeError
(
"
Validation failed
"
)
else
:
print
(
"
No validation schema given, continue at your own risk.
"
)
# Filling the data
# Filling the data
result_wb
=
load_workbook
(
template
)
result_wb
=
load_workbook
(
template
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment