diff --git a/etl/route_march_data_pull/app.py b/etl/route_march_data_pull/app.py index 11dd19b8..3c8cfa31 100644 --- a/etl/route_march_data_pull/app.py +++ b/etl/route_march_data_pull/app.py @@ -21,7 +21,7 @@ load_dotenv(dotenv_path="backend/.env") EPC_AUTH_TOKEN = os.getenv("EPC_AUTH_TOKEN") -def get_data(asset_list, fulladdress_column, address1_column, postcode_column): +def get_data(asset_list, fulladdress_column, address1_column, postcode_column, manual_uprn_map): epc_data = [] errors = [] no_epc = [] @@ -34,6 +34,7 @@ def get_data(asset_list, fulladdress_column, address1_column, postcode_column): house_no = SearchEpc.get_house_number(address=str(house_number), postcode=postcode) if house_no is None: house_no = house_number + uprn = manual_uprn_map.get(full_address, None) searcher = SearchEpc( address1=str(house_no), @@ -43,7 +44,8 @@ def get_data(asset_list, fulladdress_column, address1_column, postcode_column): property_type=None, fast=True, full_address=full_address, - max_retries=5 + max_retries=5, + uprn=uprn ) # Force the skipping of estimating the EPC searcher.ordnance_survey_client.property_type = None @@ -52,7 +54,7 @@ def get_data(asset_list, fulladdress_column, address1_column, postcode_column): searcher.find_property(skip_os=True) # Check if we have a flat or appartment - if searcher.newest_epc is None: + if searcher.newest_epc is None and uprn is None: # Try again: if SearchEpc.get_house_number(address=str(house_number), postcode=postcode) is None: # Backup @@ -161,6 +163,13 @@ def app(): ADDRESS1_METHOD = "first_two_words" ADDRESS_COLS_TO_CONCAT = ["House No", "Street", "District"] + # Maps addresses to uprn in problematic cases + MANUAL_UPRN_MAP = { + "1 Ivy Court, The Gardens, Erdington, Birmingham": 100071442178, + "8 Ivy Court, The Gardens, Erdington, Birmingham": 10033393299, + "7 Ivy Court, The Gardens, Erdington, Birmingham": 100071442184, + } + asset_list = pd.read_excel(os.path.join(DATA_FOLDER, DATA_FILENAME), header=0, sheet_name=SHEET_NAME) asset_list = asset_list[~pd.isnull(asset_list[POSTCODE_COLUMN])].reset_index() asset_list["row_id"] = asset_list.index @@ -193,7 +202,8 @@ def app(): asset_list=asset_list, fulladdress_column=FULLADDRESS_COLUMN, address1_column=ADDRESS1_COLUMN, - postcode_column=POSTCODE_COLUMN + postcode_column=POSTCODE_COLUMN, + manual_uprn_map=MANUAL_UPRN_MAP ) # We now retrieve any failed properties