Utilities
Module for utilities that can be used throughout library
- ec3.ec3_utils.get_displayname_category_dict(category_tree)
Get a dictionary with display names as the keys and ids as the values
- ec3.ec3_utils.get_masterformat_category_dict(category_tree)
Get a dictionary with masterformat codes as the keys and ids as the values
- ec3.ec3_utils.postal_to_latlong(postal_code, country_code='US')
Converts postal code to latitude and longitude returned as array. Refer to pgeocode documentation for supported country codes. If not found, then coordinates for Null Island are returned (0,0).
- ec3.ec3_utils.recursive_dict_list_return(dict_item, key_name, out_keys, outlist=[])
Recursively loops through a nested json/dictionary based on the key name
This is intended for where the key_name may occur at multiple levels of nesting. For example, the “subcategories” key occurs at multiple levels of the EC3 categories tree. Using this function allows you to return a flattened list of dictionaries with the desired keys defined in the “out_keys” argument.
- Parameters
- Returns
List of dictionaries with keys provided in out_keys
- Return type