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
6ff421ed
Commit
6ff421ed
authored
3 years ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Plain Diff
Merge branch 'f-better-output' into 'dev'
MAINT: enhance output when table cannot be parsed See merge request
!25
parents
b3a7eb6c
a3d1b08d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!25
MAINT: enhance output when table cannot be parsed
Pipeline
#16667
failed
3 years ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
1
Pipelines
18
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosadvancedtools/table_importer.py
+14
-8
14 additions, 8 deletions
src/caosadvancedtools/table_importer.py
with
14 additions
and
8 deletions
src/caosadvancedtools/table_importer.py
+
14
−
8
View file @
6ff421ed
...
...
@@ -51,7 +51,7 @@ def assure_name_format(name):
name
=
str
(
name
)
if
len
(
name
.
split
(
"
,
"
))
!=
2
:
raise
ValueError
(
"
Nam
e field should be
'
LastName, FirstName
'
.
"
raise
ValueError
(
"
Th
e field
value
should be
'
LastName, FirstName
'
.
"
"
The supplied value was
'
{}
'
.
"
.
format
(
name
))
return
name
...
...
@@ -303,14 +303,20 @@ class TableImporter(object):
"""
for
key
,
datatype
in
self
.
datatypes
.
items
():
for
idx
,
val
in
df
.
loc
[
pd
.
notnull
(
df
.
loc
[:,
key
]),
key
].
iteritems
():
for
idx
,
val
in
df
.
loc
[
pd
.
notnull
(
df
.
loc
[:,
key
]),
key
].
iteritems
():
if
not
isinstance
(
val
,
datatype
):
raise
DataInconsistencyError
(
"
In row no. {rn} and column {c} of file
'
{fi}
'
the
"
msg
=
(
"
In row no. {rn} and column
'
{c}
'
of file
'
{fi}
'
the
"
"
datatype was {was} but it should be
"
"
{expected}
"
.
format
(
rn
=
idx
,
c
=
key
,
fi
=
filename
,
was
=
type
(
val
),
expected
=
datatype
)
was
=
str
(
type
(
val
)).
strip
(
"
<>
"
),
expected
=
str
(
datatype
).
strip
(
"
<>
"
))
)
logger
.
warning
(
msg
,
extra
=
{
'
identifier
'
:
filename
,
'
category
'
:
"
inconsistency
"
})
raise
DataInconsistencyError
(
msg
)
def
check_missing
(
self
,
df
,
filename
=
None
):
"""
...
...
@@ -394,7 +400,7 @@ class XLSImporter(TableImporter):
df
=
xls_file
.
parse
(
converters
=
self
.
converters
,
**
kwargs
)
except
Exception
as
e
:
logger
.
warning
(
"
Cannot parse {}.
"
.
format
(
filename
),
"
Cannot parse {}.
\n
{}
"
.
format
(
filename
,
e
),
extra
=
{
'
identifier
'
:
str
(
filename
),
'
category
'
:
"
inconsistency
"
})
raise
DataInconsistencyError
(
*
e
.
args
)
...
...
@@ -411,7 +417,7 @@ class CSVImporter(TableImporter):
**
kwargs
)
except
ValueError
as
ve
:
logger
.
warning
(
"
Cannot parse {}.
"
.
format
(
filename
),
"
Cannot parse {}.
\n
{}
"
.
format
(
filename
,
ve
),
extra
=
{
'
identifier
'
:
str
(
filename
),
'
category
'
:
"
inconsistency
"
})
raise
DataInconsistencyError
(
*
ve
.
args
)
...
...
@@ -428,7 +434,7 @@ class TSVImporter(TableImporter):
**
kwargs
)
except
ValueError
as
ve
:
logger
.
warning
(
"
Cannot parse {}.
"
.
format
(
filename
),
"
Cannot parse {}.
\n
{}
"
.
format
(
filename
,
ve
),
extra
=
{
'
identifier
'
:
str
(
filename
),
'
category
'
:
"
inconsistency
"
})
raise
DataInconsistencyError
(
*
ve
.
args
)
...
...
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