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
49a973b1
Verified
Commit
49a973b1
authored
4 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Plain Diff
Merge branch 'table' into lfilter
parents
08c07e4a
a76a989e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!22
Release 0.3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caosadvancedtools/table_importer.py
+9
-10
9 additions, 10 deletions
src/caosadvancedtools/table_importer.py
with
9 additions
and
10 deletions
src/caosadvancedtools/table_importer.py
+
9
−
10
View file @
49a973b1
...
...
@@ -48,7 +48,8 @@ def yes_no_converter(val):
class
XLS_Importer
(
object
):
def
__init__
(
self
,
converters
,
obligatory_columns
=
[],
unique_columns
=
[]):
def
__init__
(
self
,
converters
,
obligatory_columns
=
None
,
unique_columns
=
None
):
"""
converters: dict with column names as keys and converter functions as
...
...
@@ -63,8 +64,8 @@ class XLS_Importer(object):
"""
self
.
sup
=
SuppressKnown
()
self
.
required_columns
=
list
(
converters
.
keys
())
self
.
obligatory_columns
=
obligatory_columns
self
.
unique_columns
=
unique_columns
self
.
obligatory_columns
=
[]
if
obligatory_columns
is
None
else
obligatory_columns
self
.
unique_columns
=
[]
if
unique_columns
is
None
else
unique_columns
self
.
converters
=
converters
def
read_xls
(
self
,
filename
):
...
...
@@ -72,10 +73,8 @@ class XLS_Importer(object):
if
len
(
xls_file
.
sheet_names
)
>
1
:
# Multiple sheets is the default now. Only show in debug
logger
.
debug
(
"
Excel file {} contains multiple sheets.
"
"
All but the first are being ignored.
"
.
format
(
filename
))
logger
.
debug
(
"
Excel file %s contains multiple sheets.
"
"
All but the first are being ignored.
"
,
filename
)
df
=
xls_file
.
parse
(
converters
=
self
.
converters
)
self
.
check_columns
(
df
,
filename
=
filename
)
...
...
@@ -97,9 +96,9 @@ class XLS_Importer(object):
df
=
df
.
copy
()
uniques
=
[]
for
index
,
row
in
df
.
iterrows
():
element
=
tuple
(
row
.
loc
[
key
]
for
key
in
self
.
unique_columns
)
subtable
=
df
[
list
(
self
.
unique_columns
)]
for
index
,
row
in
subtable
.
iterrows
():
element
=
tuple
(
row
)
if
element
in
uniques
:
errmsg
=
(
"
The {}. row contains the values
'
{}
'
.
\n
This value
"
...
...
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