diff --git a/etl/eligibility/ha_15_32/ha_analysis_batch_3.py b/etl/eligibility/ha_15_32/ha_analysis_batch_3.py index 0c9f685f..4ae881d2 100644 --- a/etl/eligibility/ha_15_32/ha_analysis_batch_3.py +++ b/etl/eligibility/ha_15_32/ha_analysis_batch_3.py @@ -155,6 +155,10 @@ class DataLoader: "HA24": { "address": "Address", "postcode": "Postcode" + }, + "HA25": { + "address": "T1_Address", + "postcode": "matching_postcode" } } @@ -178,7 +182,7 @@ class DataLoader: def create_asset_list_matching_address(self, ha_name, asset_list): - if ha_name in ["HA1", "HA6", "HA16", "HA24"]: + if ha_name in ["HA1", "HA6", "HA16", "HA24", "HA25"]: asset_list["matching_address"] = asset_list[ self.COLUMN_CONFIG[ha_name]["address"] ].astype(str).str.lower().str.strip() @@ -374,13 +378,23 @@ class DataLoader: asset_sheetname = self.get_asset_sheetname(workbook) asset_sheet = workbook[asset_sheetname] asset_sheet_colnames = [cell.value for cell in asset_sheet[1]] + if ha_name == "HA25": + asset_sheet_colnames[11] = "matching_postcode" + + values_only = not ha_name != "HA25" rows_data = [] - for row in asset_sheet.iter_rows(min_row=2, values_only=False): - row_data = [cell.value for cell in row] # This will get you the cell values - rows_data.append(row_data) + if not values_only: + for row in asset_sheet.iter_rows(min_row=2, values_only=values_only): + row_data = [cell.value for cell in row] # This will get you the cell values + rows_data.append(row_data) + else: + for row in asset_sheet.iter_rows(min_row=2, values_only=values_only): # use values_only=True to get values + row_data = list(row) # No need for comprehension, values_only=True returns a tuple of values + rows_data.append(row_data) asset_list = pd.DataFrame(rows_data, columns=asset_sheet_colnames) + asset_list = asset_list.loc[:, asset_list.columns.notnull()] # Remove entirely empty rows - consider all rows apart from row_color @@ -403,9 +417,10 @@ class DataLoader: asset_list_correction_function = getattr(self, f"correct_{ha_name.lower()}_asset_list") asset_list = asset_list_correction_function(asset_list) - # For HA1, there is an exception in the structure of the data. We don't have any survey or ciga lists, and so + # For HA1 and HA25, there is an exception in the structure of the data. We don't have any survey or ciga + # lists, and so # we can return the asset list now - if ha_name == "HA1": + if ha_name in ["HA1", "HA25"]: return asset_list, pd.DataFrame(), pd.DataFrame() # We check if there is a survey list @@ -1149,7 +1164,8 @@ class DataLoader: "ECO4": "ECO4", "AFFORDABLE WARMTH": "ECO4", "ECO4 A/W": "ECO4", - "ECO4 GBIS (ECO+)": "GBIS" + "ECO4 GBIS (ECO+)": "GBIS", + "ECO4 GBIS (ECO+) JJC UNDER 73m²": "GBIS" } eco_eligibility_map = { @@ -3305,6 +3321,8 @@ def app(): december_figures_filepath = "local_data/ha_data/HA_December_figures.csv" priority_has = ["HA1", "HA6", "HA7", "HA14", "HA16", "HA24", "HA25", "HA39", "HA107"] + # Next HAs to do: 15, 32, 33, + # Then: 28, 41, 38, 10, 14, 20, 48 # Filter down the directories to only the priority HAs directories = [d for d in directories if d.split("/")[2] in priority_has]