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
5b6cd1b0
Commit
5b6cd1b0
authored
1 year ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: obligatory no longer forces columns to exist
parent
81ccbd95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!73
MAINT: change wording of TableImporter argument and allow converters and...
,
!70
ENH: allow to provide required columns explicitly
Pipeline
#35528
passed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-1
2 additions, 1 deletion
CHANGELOG.md
src/caosadvancedtools/table_importer.py
+2
-2
2 additions, 2 deletions
src/caosadvancedtools/table_importer.py
unittests/test_table_importer.py
+0
-4
0 additions, 4 deletions
unittests/test_table_importer.py
with
4 additions
and
7 deletions
CHANGELOG.md
+
2
−
1
View file @
5b6cd1b0
...
...
@@ -8,10 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ###
-
TableImporter now accepts a
`existing_columns`
argument which demands that certain columns exist
although they may have missing values
### Changed ###
-
The converters and datatype arguments of TableImporter now may have keys for nonexisting columns
-
The obligatory key word no longer enforces that the columns exist. Since all rows are still
checked whether this column has a non-NULL value, this is deemed a non breaking change.
### Deprecated ###
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/table_importer.py
+
2
−
2
View file @
5b6cd1b0
...
...
@@ -221,7 +221,7 @@ class TableImporter():
value check is not necessary.
obligatory_columns : list, optional
List of column names
, each listed column must exist and
must not have missing values.
List of column names
that
must not have missing values.
unique_keys : list, optional
List of column names that in combination must be unique: each row has a unique
...
...
@@ -272,7 +272,7 @@ class TableImporter():
"""
for
col
in
self
.
obligatory_columns
+
self
.
existing_columns
:
for
col
in
self
.
existing_columns
:
if
col
not
in
df
.
columns
:
errmsg
=
"
Column
'
{}
'
missing in
"
.
format
(
col
)
errmsg
+=
(
"
\n
{}.
\n
"
.
format
(
filename
)
if
filename
...
...
This diff is collapsed.
Click to expand it.
unittests/test_table_importer.py
+
0
−
4
View file @
5b6cd1b0
...
...
@@ -153,10 +153,6 @@ class TableImporterTest(unittest.TestCase):
[[
'
a
'
,
1
,
2.0
,
'
yes
'
,
np
.
nan
]],
columns
=
[
'
a
'
,
'
b
'
,
'
c
'
,
'
d
'
,
'
e
'
])
def
test_missing_col
(
self
):
# check missing from obligatory
df
=
pd
.
DataFrame
(
columns
=
[
'
a
'
,
'
e
'
])
importer
=
TableImporter
(
**
self
.
importer_kwargs
)
self
.
assertRaises
(
ValueError
,
importer
.
check_columns
,
df
)
# check missing from existing
df
=
pd
.
DataFrame
(
columns
=
[
'
a
'
,
'
b
'
])
importer
=
TableImporter
(
**
self
.
importer_kwargs
)
...
...
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