Skip to content

Instantly share code, notes, and snippets.

@alem0lars
Created February 13, 2018 16:47
Show Gist options
  • Save alem0lars/626b2fdd2ef10c5d14dab471b9974986 to your computer and use it in GitHub Desktop.
Save alem0lars/626b2fdd2ef10c5d14dab471b9974986 to your computer and use it in GitHub Desktop.
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