Created
February 13, 2018 16:47
-
-
Save alem0lars/626b2fdd2ef10c5d14dab471b9974986 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _compare_equality(x, y): | |
if is_number: | |
return x == y | |
else: | |
regex = re.compile(y.replace("*", ".*"), re.IGNORECASE) | |
return regex.search(x) | |
def compare_equality(data, query, col, is_number): | |
return filter_data(_compare_equality, data, query, col, is_number) | |
def filter_data(fn, data, operand, col, is_number): | |
if is_number: | |
operand = int(operand) | |
return list( | |
filter(lambda row: fn(row[col], operand), data) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment