Skip to content
Snippets Groups Projects
Commit 9af4f269 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

Merge branch 'lfilter' into logging-setup

parents 0067c2a2 c6a80f03
Branches
No related tags found
No related merge requests found
__pycache__
.tox
.eggs
.coverage
*cache.db
*.egg-info
.docker/cert
src/caosadvancedtools/version.py
......@@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ###
- the suppression module is now a logging filter
- The suppression module is now a logging filter
- The WebUIHandler is now a python logging formatter.
- instead of `get_entity`, type-specific functions are used in
`cfood.py` when the type of the entity in question is known.
......
......@@ -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 '{}'.\nThis value "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment