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
246b0a95
Commit
246b0a95
authored
4 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
FIX: use filter in table_importer
parent
15d51179
No related branches found
No related tags found
1 merge request
!22
Release 0.3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/suppressKnown.py
+1
-1
1 addition, 1 deletion
src/caosadvancedtools/suppressKnown.py
src/caosadvancedtools/table_importer.py
+13
-13
13 additions, 13 deletions
src/caosadvancedtools/table_importer.py
with
14 additions
and
14 deletions
src/caosadvancedtools/suppressKnown.py
+
1
−
1
View file @
246b0a95
...
...
@@ -22,7 +22,7 @@ class SuppressKnown(logging.Filter):
when they are known.
"""
def
__init__
(
self
,
db_file
=
None
,
logger
=
None
):
def
__init__
(
self
,
db_file
=
None
):
if
db_file
:
self
.
db_file
=
db_file
else
:
...
...
This diff is collapsed.
Click to expand it.
src/caosadvancedtools/table_importer.py
+
13
−
13
View file @
246b0a95
...
...
@@ -22,7 +22,7 @@ import logging
import
numpy
as
np
import
pandas
as
pd
from
caosadvancedtools.suppress
able
import
Suppress
able
from
caosadvancedtools.suppress
Known
import
Suppress
Known
logger
=
logging
.
getLogger
(
"
caosadvancedtools
"
)
...
...
@@ -61,7 +61,7 @@ class XLS_Importer(object):
obligatory_columns: list of column names, optional
each listed column must not have missing values
"""
self
.
sup
=
Suppress
able
(
logger
=
logger
)
self
.
sup
=
Suppress
Known
(
)
self
.
required_columns
=
list
(
converters
.
keys
())
self
.
obligatory_columns
=
obligatory_columns
self
.
unique_columns
=
unique_columns
...
...
@@ -89,9 +89,9 @@ class XLS_Importer(object):
def
check_columns
(
self
,
df
,
filename
=
None
):
for
col
in
self
.
required_columns
:
if
col
not
in
df
.
columns
:
errms
s
g
=
"
Column
'
{}
'
missing in
"
.
format
(
col
)
errms
s
g
+=
"
{}.
"
.
format
(
filename
)
if
filename
else
"
the file.
"
raise
ValueError
(
errms
s
g
)
errmsg
=
"
Column
'
{}
'
missing in
"
.
format
(
col
)
errmsg
+=
"
{}.
"
.
format
(
filename
)
if
filename
else
"
the file.
"
raise
ValueError
(
errmsg
)
def
check_unique
(
self
,
df
,
filename
=
None
):
df
=
df
.
copy
()
...
...
@@ -101,15 +101,15 @@ class XLS_Importer(object):
element
=
tuple
(
row
.
loc
[
key
]
for
key
in
self
.
unique_columns
)
if
element
in
uniques
:
errms
s
g
=
(
errmsg
=
(
"
The {}. row contains the values
'
{}
'
.
\n
This value
"
"
combination should be unique, but was used in a previous
"
"
row in
\n
"
).
format
(
index
+
1
,
element
)
errms
s
g
+=
"
{}.
"
.
format
(
filename
)
if
filename
else
"
the file.
"
errms
s
g
+=
"
\n
This row will be ignored!
"
errmsg
+=
"
{}.
"
.
format
(
filename
)
if
filename
else
"
the file.
"
errmsg
+=
"
\n
This row will be ignored!
"
self
.
sup
.
warning
(
errms
s
g
,
identifier
=
filename
,
category
=
"
inconsistency
"
)
logger
.
warning
(
errmsg
,
extra
=
{
'
identifier
'
:
filename
,
'
category
'
:
"
inconsistency
"
}
)
df
=
df
.
drop
(
index
)
else
:
uniques
.
append
(
element
)
...
...
@@ -134,13 +134,13 @@ class XLS_Importer(object):
for
key
in
self
.
obligatory_columns
:
if
pd
.
isnull
(
row
.
loc
[
key
]):
errms
s
g
=
(
errmsg
=
(
"
Required information is missing ({}) in {}. row
"
"
(without header) of
"
"
file:
\n
{}
"
.
format
(
key
,
index
+
1
,
filename
))
self
.
sup
.
warning
(
errms
s
g
,
identifier
=
filename
,
category
=
"
inconsistency
"
)
logger
.
warning
(
errmsg
,
extra
=
{
'
identifier
'
:
filename
,
'
category
'
:
"
inconsistency
"
}
)
df
=
df
.
drop
(
index
)
continue
...
...
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