Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mapping is again refined
mapping_functions = {
'str_lower' : lambda x: x.lower(),
'date_mdY' : lambda x: datetime.strptime(x, "%m/%d/%Y"),
'ssn' : lambda x: int(x.replace('-', ''))
'int' : lambda x: int(x)
'dom' : lambda x: int(m.parseString(x).childNodes[0].childNodes[0].nodeValue)
}
mapping_tbl = []
mapping_tbl.insert(0, mapping_functions['dom'])
mapping_tbl.insert(1, mapping_functions['str_lower'])
mapping_tbl.insert(2, mapping_functions['str_lower'])
mapping_tbl.insert(3, mapping_functions['int'])
mapping_tbl.insert(4, mapping_functions['date_mdY'])
mapping_tbl.insert(5, mapping_functions['ssn'])
mapping_tbl.insert(6, mapping_functions['date_mdY'])
mapping_tbl.insert(7, mapping_functions['date_mdY'])
mapping_tbl.insert(8, mapping_functions['str_lower'])
mapping_tbl.insert(9, mapping_functions['str_lower'])
search_data = sorted(search_data, key=cmp_to_key(column_to_sort, mapping_tbl[column_to_sort]), reverse = (sort_dir != "asc"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment