From a89d0aeb31550599a4d55d06857f23621130a45e Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Fri, 17 Oct 2025 09:27:21 +0000 Subject: [PATCH] quick fix for script --- ...onth_end_automation_wave_accent_housing.py | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/etl/month_end_automation_wave_accent_housing.py b/etl/month_end_automation_wave_accent_housing.py index 318c208..6541a9b 100644 --- a/etl/month_end_automation_wave_accent_housing.py +++ b/etl/month_end_automation_wave_accent_housing.py @@ -168,29 +168,31 @@ if not epc_ns.empty: filtered_dfs.append(epc_ns) +final_df = None +if filtered_dfs: + final_df = pd.concat(filtered_dfs).reset_index(drop=True) -final_df = pd.concat(filtered_dfs).reset_index(drop=True) +if final_df: + final_df["job_type"] = final_df["job_type"].str.lower() + rate_card_df["job_type"] = rate_card_df["job_type"].str.lower() -final_df["job_type"] = final_df["job_type"].str.lower() -rate_card_df["job_type"] = rate_card_df["job_type"].str.lower() + # Now perform the merge + combined_with_rates = final_df.merge(rate_card_df, on="job_type", how="left") + import datetime + timestamp = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M') -# Now perform the merge -combined_with_rates = final_df.merge(rate_card_df, on="job_type", how="left") -import datetime -timestamp = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M') + # Upload to sharepoint + attribute = ['address', 'client', 'job_type', 'rate'] + master_folder_name = "2501 Accent housing" + file_name = f"{master_folder_name}_{timestamp}.xlsx" + combined_with_rates[attribute].to_excel(file_name, index=False) -# Upload to sharepoint -attribute = ['address', 'client', 'job_type', 'rate'] -master_folder_name = "2501 Accent housing" -file_name = f"{master_folder_name}_{timestamp}.xlsx" -combined_with_rates[attribute].to_excel(file_name, index=False) + file_path = os.path.abspath(file_name) -file_path = os.path.abspath(file_name) + upload_to_month_end_folder(file_name, file_path, master_folder_name) -upload_to_month_end_folder(file_name, file_path, master_folder_name) - -invoice_name = "rate_card.xlsx" -file_path = os.path.abspath(invoice_name) -rate_card_df.to_excel(invoice_name, index=False) -upload_to_month_end_folder(invoice_name, file_path, master_folder_name) + invoice_name = "rate_card.xlsx" + file_path = os.path.abspath(invoice_name) + rate_card_df.to_excel(invoice_name, index=False) + upload_to_month_end_folder(invoice_name, file_path, master_folder_name)