From 1e63b9567e6c8bc516f7c643e1ac771963fcf26f Mon Sep 17 00:00:00 2001 From: Florent Ravenel Date: Thu, 28 Mar 2024 00:26:33 +0100 Subject: [PATCH] feat: add entity index + update send to gsheet --- ...ogle_Sheets_Send_content_db_to_spreadsheet.ipynb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/models/content-engine/core/domain/Google_Sheets_Send_content_db_to_spreadsheet.ipynb b/models/content-engine/core/domain/Google_Sheets_Send_content_db_to_spreadsheet.ipynb index 0fbe622..fb9de3b 100644 --- a/models/content-engine/core/domain/Google_Sheets_Send_content_db_to_spreadsheet.ipynb +++ b/models/content-engine/core/domain/Google_Sheets_Send_content_db_to_spreadsheet.ipynb @@ -131,13 +131,14 @@ "outputs": [], "source": [ "# Inputs\n", - "entity_dir = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", \"0\"), \"entity_dir\") or \"\"\n", - "entity_name = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", \"0\"), \"entity_name\") or \"\"\n", + "entity_index = \"0\"\n", + "entity_dir = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", entity_index), \"entity_dir\") or \"\"\n", + "entity_name = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", entity_index), \"entity_name\") or \"\"\n", "input_dir = os.path.join(entity_dir, \"content-engine\", date.today().isoformat())\n", "file_name = \"linkedin_posts\"\n", "\n", "# Outputs\n", - "spreadsheet_url = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", \"0\"), \"abi_spreadsheet\") or \"\"\n", + "spreadsheet_url = pload(os.path.join(naas_data_product.OUTPUTS_PATH, \"entities\", entity_index), \"abi_spreadsheet\") or \"\"\n", "sheet_name = \"POSTS\"\n", "output_dir = os.path.join(entity_dir, \"content-engine\", date.today().isoformat())\n", "file_content = \"posts\"" @@ -353,11 +354,7 @@ }, "outputs": [], "source": [ - "df_check = pd.concat([df_init.astype(str), df_content.astype(str)]).drop_duplicates(keep=False)\n", - "if len(df_check) > 0:\n", - " gsheet.connect(spreadsheet_url).send(sheet_name=sheet_name, data=df_content, append=False)\n", - "else:\n", - " print(\"Noting to update in Google Sheets!\")" + "send_data_to_gsheet(df_content, df_init, spreadsheet_url, sheet_name)" ] }, {