Skip to content
Snippets Groups Projects
Verified Commit 49a973b1 authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'table' into lfilter

parents 08c07e4a a76a989e
No related branches found
No related tags found
1 merge request!22Release 0.3
......@@ -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.
Finish editing this message first!
Please register or to comment