diff --git a/hugvey/tools.py b/hugvey/tools.py index 1935e8b..5087026 100644 --- a/hugvey/tools.py +++ b/hugvey/tools.py @@ -234,7 +234,20 @@ class Toolbox: raise Exception("Not all required fieldnames are given in csv: id, translation, regex_translation") for row in reader: - node = [node for node in story if node['@id'] == row['id']][0] + if not any(row.values()): + logger.info(f"Skipping empty row") + continue + if not row['id']: + logger.critical(f"Skipping row without ID, but with data: {list(row.values())}") + continue + + try: + node = [node for node in story if node['@id'] == row['id']][0] + except Exception as e: + logger.critical(f"Exception finding node id {row}") + logger.exception(e) + raise(e) + if node['@type'] == 'Msg': if len(row['translation']) < 1 and len(node['text']) > 0: logger.warning(f"Skipping empty translation for message {node['@id']} \"{node['text']}\"")