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
db54ff43
Commit
db54ff43
authored
1 year ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
wip
parent
3931c9bd
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
#48476
failed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
+14
-13
14 additions, 13 deletions
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
src/caosadvancedtools/table_json_conversion/table_generator.py
+1
-1
1 addition, 1 deletion
...aosadvancedtools/table_json_conversion/table_generator.py
with
15 additions
and
14 deletions
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
+
14
−
13
View file @
db54ff43
...
...
@@ -54,11 +54,10 @@ def _get_column_types(sheet: Worksheet) -> OrderedDict:
type_row_index
=
_get_row_type_column_index
(
sheet
)
for
idx
,
col
in
enumerate
(
sheet
.
columns
):
type_cell
=
col
[
type_row_index
]
result
[
idx
]
=
type_cell
.
value
assert
(
hasattr
(
ColumnType
,
type_cell
.
value
)
or
type_cell
.
value
==
RowType
.
COL_TYPE
.
name
or
type_cell
.
value
is
None
),
(
f
"
Unexpected column type value:
{
type_cell
.
value
}
"
)
result
[
idx
]
=
type_cell
.
value
if
type_cell
.
value
is
not
None
else
ColumnType
.
IGNORE
.
name
assert
(
hasattr
(
ColumnType
,
result
[
idx
])
or
result
[
idx
]
==
RowType
.
COL_TYPE
.
name
),
(
f
"
Unexpected column type value (
{
idx
}{
type_row_index
}
):
{
type_cell
.
value
}
"
)
return
result
...
...
@@ -281,16 +280,17 @@ out: union[dict, None]
next_context
=
context
.
next_level
(
name
)
# preprocessing
if
isinstance
(
content
,
list
):
if
not
content
:
if
not
content
:
# empty list
continue
#
M
ust be all of the same type.
#
list elements m
ust be all of the same type.
assert
len
(
set
(
type
(
entry
)
for
entry
in
content
))
==
1
if
isinstance
(
content
[
0
],
dict
):
if
isinstance
(
content
[
0
],
dict
):
# all elements are dicts
# An array of objects: must go into exploded sheet
for
entry
in
content
:
self
.
_handle_data
(
data
=
entry
,
current_path
=
path
,
context
=
next_context
)
continue
elif
isinstance
(
content
,
dict
):
elif
isinstance
(
content
,
dict
):
# we recurse and simply use the result
if
not
current_path
:
# Special handling for top level
self
.
_handle_data
(
content
,
current_path
=
path
,
context
=
next_context
)
continue
...
...
@@ -301,26 +301,27 @@ out: union[dict, None]
insertables
.
update
(
insert
)
continue
else
:
# scalars
content
=
[
content
]
content
=
[
content
]
# make list for unified treatment below
# collecting the data
assert
isinstance
(
content
,
list
)
assert
isinstance
(
content
,
list
)
# TODO do we want this??? make list non-lists?
if
len
(
content
)
==
1
:
value
=
content
[
0
]
else
:
value
=
"
;
"
.
join
(
content
)
value
=
"
;
"
.
join
(
content
)
# TODO we need escaping of values
path_str
=
p2s
(
path
)
assert
path_str
not
in
insertables
insertables
[
path_str
]
=
value
if
only_collect_insertables
:
return
insertables
if
not
current_path
:
if
not
current_path
:
# top level returns (?)
return
None
# actual data insertion
insert_row
=
None
sheet
=
None
for
path_str
,
value
in
insertables
.
items
():
sheet_meta
=
self
.
_sheet_index
[
path_str
]
if
sheet
is
None
:
sheet
=
sheet_meta
.
sheet
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/table_json_conversion/table_generator.py
+
1
−
1
View file @
db54ff43
...
...
@@ -42,7 +42,7 @@ class ColumnType(Enum):
SCALAR
=
1
LIST
=
2
FOREIGN
=
3
IGNORE
=
3
IGNORE
=
4
class
RowType
(
Enum
):
...
...
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