diff --git a/backend/SearchEpc.py b/backend/SearchEpc.py index b5ec8c46..e7e717ac 100644 --- a/backend/SearchEpc.py +++ b/backend/SearchEpc.py @@ -405,7 +405,8 @@ class SearchEpc: else: raise ValueError("Multiple UPRNs found - investigate me") - uprn = uprns.pop() if uprns else None + # If we do not have a UPRN, we create one based on a hash of the address & postcoce + uprn = uprns.pop() if uprns else hash(self.address1 + self.postcode) if self.fast: return newest_epc, [], {}, "", "", None diff --git a/etl/customers/eon/pilot_asset_list.py b/etl/customers/eon/pilot_asset_list.py index 05e459cb..298b34ba 100644 --- a/etl/customers/eon/pilot_asset_list.py +++ b/etl/customers/eon/pilot_asset_list.py @@ -170,39 +170,39 @@ def app(): # For each property, retrieve UPRN with from the Ordnance Survey API. To do this, I have created a free # trial with Ordnance Survey with my personal account as a temporary solution. # Let's just pull the full EPC data for this - asset_list_with_uprn = [] - for row, property_meta in tqdm(raw_asset_list_base.iterrows(), total=raw_asset_list_base.shape[0]): - if row <= 104: - continue - time.sleep(1.1) - searcher = SearchEpc( - address1=property_meta["address"], - postcode=property_meta["postcode"], - auth_token=EPC_AUTH_TOKEN, - os_api_key=ORDNANCE_SURVEY_API_KEY, - full_address=", ".join([property_meta["address"], property_meta["postcode"]]) - ) - - # Let's just find the UPRN - searcher.ordnance_survey_client.get_places_api() - - uprn = searcher.ordnance_survey_client.most_relevant_result["UPRN"] - - # searcher.find_property(skip_os=False) - - asset_list_with_uprn.append( - { - **property_meta, - "uprn": uprn, - } - ) + # asset_list_with_uprn = [] + # for row, property_meta in tqdm(raw_asset_list_base.iterrows(), total=raw_asset_list_base.shape[0]): + # if row <= 104: + # continue + # time.sleep(1.1) + # searcher = SearchEpc( + # address1=property_meta["address"], + # postcode=property_meta["postcode"], + # auth_token=EPC_AUTH_TOKEN, + # os_api_key=ORDNANCE_SURVEY_API_KEY, + # full_address=", ".join([property_meta["address"], property_meta["postcode"]]) + # ) + # + # # Let's just find the UPRN + # searcher.ordnance_survey_client.get_places_api() + # + # uprn = searcher.ordnance_survey_client.most_relevant_result["UPRN"] + # + # # searcher.find_property(skip_os=False) + # + # asset_list_with_uprn.append( + # { + # **property_meta, + # "uprn": uprn, + # } + # ) # Store this as a backup # import pandas as pd # asset_list_with_uprn_df = pd.DataFrame(asset_list_with_uprn) # asset_list_with_uprn_df.to_csv("eon_asset_list_with_uprn.csv", index=False) # Read in - # asset_list_with_uprn = pd.read_csv("eon_asset_list_with_uprn.csv").to_dict(orient="records") + asset_list_with_uprn = pd.read_csv("eon_asset_list_with_uprn.csv").to_dict(orient="records") # Store the asset list and create the portfolio payload asset_list_with_uprn_df = pd.DataFrame(asset_list_with_uprn)