created hashing of uprn

This commit is contained in:
Khalim Conn-Kowlessar 2024-10-01 16:27:17 +01:00
parent ad37630d80
commit c5b7775a23
2 changed files with 29 additions and 28 deletions

View file

@ -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

View file

@ -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)