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
e93984c0
Commit
e93984c0
authored
11 months ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
WIP: XLSX reader
parent
381ba467
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!107
Release v0.11.0
,
!102
ENH: XLSX reader
Checking pipeline status
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/table_json_conversion/convert.py
+37
-0
37 additions, 0 deletions
src/caosadvancedtools/table_json_conversion/convert.py
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
+3
-3
3 additions, 3 deletions
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
with
40 additions
and
3 deletions
src/caosadvancedtools/table_json_conversion/convert.py
0 → 100644
+
37
−
0
View file @
e93984c0
#!/usr/bin/env python3
# encoding: utf-8
#
# This file is a part of the LinkAhead Project.
#
# Copyright (C) 2024 Indiscale GmbH <info@indiscale.com>
# Copyright (C) 2024 Henrik tom Wörden <h.tomwoerden@indiscale.com>
# Copyright (C) 2024 Daniel Hornung <d.hornung@indiscale.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from
fill_xlsx
import
read_or_dict
class
XLSXConverter
:
def
__init__
(
self
,
schema
:
Union
[
dict
,
str
,
TextIO
]):
"""
Parameters
----------
schema: Union[dict, str, TextIO]
If given, validate the date against this schema first. This raises an exception if the validation
fails. May be given as dict with the schema, path to a json file as string or as a readable file
like object.
"""
self
.
_schema
=
read_or_dict
(
schema
)
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/table_json_conversion/fill_xlsx.py
+
3
−
3
View file @
e93984c0
...
@@ -118,7 +118,7 @@ def _next_row_index(sheet: Worksheet) -> int:
...
@@ -118,7 +118,7 @@ def _next_row_index(sheet: Worksheet) -> int:
return
sheet
.
max_row
return
sheet
.
max_row
def
_
read_or_dict
(
data
:
Union
[
dict
,
str
,
TextIO
])
->
dict
:
def
read_or_dict
(
data
:
Union
[
dict
,
str
,
TextIO
])
->
dict
:
"""
If data is a json file name or input stream, read data from there.
"""
"""
If data is a json file name or input stream, read data from there.
"""
if
isinstance
(
data
,
dict
):
if
isinstance
(
data
,
dict
):
pass
pass
...
@@ -414,12 +414,12 @@ validation_schema: dict, optional
...
@@ -414,12 +414,12 @@ validation_schema: dict, optional
fails. If no validation schema is given, try to ignore more errors in the data when filling the
fails. If no validation schema is given, try to ignore more errors in the data when filling the
XLSX template.
XLSX template.
"""
"""
data
=
_
read_or_dict
(
data
)
data
=
read_or_dict
(
data
)
assert
isinstance
(
data
,
dict
)
assert
isinstance
(
data
,
dict
)
# Validation
# Validation
if
validation_schema
is
not
None
:
if
validation_schema
is
not
None
:
validation_schema
=
_
read_or_dict
(
validation_schema
)
validation_schema
=
read_or_dict
(
validation_schema
)
try
:
try
:
validate
(
data
,
validation_schema
,
format_checker
=
FormatChecker
())
validate
(
data
,
validation_schema
,
format_checker
=
FormatChecker
())
except
ValidationError
as
ve
:
except
ValidationError
as
ve
:
...
...
This diff is collapsed.
Click to expand it.
Daniel Hornung
@daniel
mentioned in commit
f92407a0
·
11 months ago
mentioned in commit
f92407a0
mentioned in commit f92407a06fb26065a424e4c3ffec3986ac6cb86f
Toggle commit list
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