diff --git a/HISTORY.rst b/HISTORY.rst index 30b30fd..eeac827 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,10 @@ ======= History ======= +2024.11.19: Bugfix: error in selection of table rows + * In a loop "For rows in table" a crietrion on the value of a row might cause an + error due to mismatch of the types. This is now corrected. + 2024.11.18: Removed automatic output of structures. * While often convenient, writing out the structure at the end of the loop was not a reasonable default. If you want the structure, add a write_structure step in the diff --git a/loop_step/loop.py b/loop_step/loop.py index d9a390f..8825f8e 100644 --- a/loop_step/loop.py +++ b/loop_step/loop.py @@ -545,29 +545,31 @@ def run(self): row = self.table.iloc[self._loop_value - 1] self.logger.debug(f"Query {row[column]} {op} {value}") + _type = type(row[column]) + _value = _type(value) if op == "==": - if row[column] == value: + if row[column] == _value: break elif op == "!=": - if row[column] != value: + if row[column] != _value: break elif op == ">": - if row[column] > value: + if row[column] > _value: break elif op == ">=": - if row[column] >= value: + if row[column] >= _value: break elif op == "<": - if row[column] < value: + if row[column] < _value: break elif op == "<=": - if row[column] <= value: + if row[column] <= _value: break elif op == "contains": - if value in row[column]: + if _value in row[column]: break elif op == "does not contain": - if value not in row[column]: + if _value not in row[column]: break elif op == "contains regexp": if re.search(value, row[column]) is not None: