1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-06-19 00:17:51 +02:00

normalize key names

This commit is contained in:
Kelly Brazil
2022-08-16 21:08:44 -07:00
parent e20357663d
commit 8682a6bd0a

View File

@ -197,10 +197,11 @@ def _process(proc_data: List[Dict]) -> List[Dict]:
for esc, esc_sub in escape_map.items():
item[key] = item[key].replace(esc, esc_sub)
# remove any quotation marks from key names
if '"' in key:
new_key = key.replace('"', '')
item[new_key] = item.pop(key)
# normalize keynames
new_key = key.strip()
new_key = re.sub(r'[^a-zA-Z0-9]', '_', new_key)
new_key = new_key.strip('_')
item[new_key] = item.pop(key)
return proc_data