diff --git a/asset_list/app.py b/asset_list/app.py index 1a7788fe..df2fe9cc 100644 --- a/asset_list/app.py +++ b/asset_list/app.py @@ -21,13 +21,21 @@ EPC_AUTH_TOKEN = os.getenv("EPC_AUTH_TOKEN") def get_data( - asset_list, fulladdress_column, address1_column, postcode_column, manual_uprn_map, + df, fulladdress_column, address1_column, postcode_column, manual_uprn_map, uprn_column=None, epc_api_only=False, row_id_name="row_id" ): + # These re-map the standard property types to forms accepted by the EPC api, so we can predict EPCs + property_type_map = { + "house": "House", + "flat": "Flat", + "maisonette": "Maisonette", + "bungalow": "Bungalow", + } + epc_data = [] errors = [] no_epc = [] - for _, home in tqdm(asset_list.iterrows(), total=len(asset_list)): + for _, home in tqdm(df.iterrows(), total=len(df)): try: postcode = home[postcode_column] house_number = str(home[address1_column]).strip() @@ -42,19 +50,21 @@ def get_data( if pd.isnull(uprn): uprn = None + property_type = property_type_map.get(home[AssetList.STANDARD_PROPERTY_TYPE], None) + searcher = SearchEpc( address1=str(house_no), postcode=postcode, auth_token=EPC_AUTH_TOKEN, os_api_key="", - property_type=None, + property_type=property_type, fast=True, full_address=full_address, max_retries=5, uprn=uprn ) # Force the skipping of estimating the EPC - searcher.ordnance_survey_client.property_type = None + searcher.ordnance_survey_client.property_type = property_type searcher.ordnance_survey_client.built_form = None searcher.find_property(skip_os=True) @@ -317,7 +327,7 @@ def app(): continue chunk = asset_list.standardised_asset_list[i:i + chunk_size] epc_data_chunk, errors_chunk, no_epc_chunk = get_data( - asset_list=chunk, + df=chunk, row_id_name=asset_list.DOMNA_PROPERTY_ID, fulladdress_column=asset_list.STANDARD_FULL_ADDRESS, address1_column=asset_list.STANDARD_ADDRESS_1, diff --git a/asset_list/requirements.txt b/asset_list/requirements.txt index fd045d46..fd43ac64 100644 --- a/asset_list/requirements.txt +++ b/asset_list/requirements.txt @@ -8,4 +8,5 @@ boto3 openpyxl openai tiktoken -msgpack \ No newline at end of file +msgpack +beautifulsoup4 \ No newline at end of file