Skip to content

Commit

Permalink
more precise error messages for checkIfColumnExists util function
Browse files Browse the repository at this point in the history
  • Loading branch information
SvenLieber committed Aug 1, 2024
1 parent a3be467 commit 6564ba6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tools/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
import time
import lxml.etree as ET
#import pandas as pd
import pandas as pd
import csv
import os
import re
Expand Down Expand Up @@ -217,7 217,26 @@ def checkIfColumnsExist(inputColumnNames, outputColumnNames):
Traceback (most recent call last):
...
Exception: The following requested column is not in the input: {'d'}
If inputColumnNames is None throw an exception
>>> checkIfColumnsExist(None,['a','c'])
Traceback (most recent call last):
...
Exception: "None" instead of list of input columns given!
If outputColumnNames is None, throw an exception
>>> checkIfColumnsExist(['a','c'], None)
Traceback (most recent call last):
...
Exception: "None" instead of list of output columns given!
"""
if not inputColumnNames:
raise Exception(f'"None" instead of list of input columns given!')
if not outputColumnNames:
raise Exception(f'"None" instead of list of output columns given!')

inputColumns = set(inputColumnNames)
outputColumns = set(outputColumnNames)
nonExistentColumns = outputColumns.difference(inputColumns)
Expand Down

0 comments on commit 6564ba6

Please sign in to comment.