allow_overwrite_of_existing_spreadsheet_cells to true or false on ghseet_feeder_db

pull/343/head
Dave Mateer 2025-07-09 09:43:32 +01:00
rodzic d36cdbfa87
commit c9001f0387
2 zmienionych plików z 16 dodań i 1 usunięć

Wyświetl plik

@ -51,6 +51,11 @@
"help": "if True the stored files path will include 'workbook_name/worksheet_name/...'",
"type": "bool",
},
"allow_overwrite_of_spreadsheet_cells": {
"default": False,
"help": "If True, the spreadsheet cells will be overwritten with the new values",
"type": "bool",
},
},
"description": """
GsheetsFeederDatabase

Wyświetl plik

@ -141,7 +141,17 @@ class GsheetsFeederDB(Feeder, Database):
def batch_if_valid(col, val, final_value=None):
final_value = final_value or val
try:
if val and gw.col_exists(col) and gw.get_cell(row_values, col) == "":
if val and gw.col_exists(col):
existing_value = gw.get_cell(row_values, col)
if existing_value:
if self.allow_overwrite_of_spreadsheet_cells:
logger.info(f"Overwriting spreadsheet cell {col}={existing_value} with {final_value}")
else:
logger.warning(f"NOT overwriting spreadsheet cell {col}={existing_value} with {final_value}")
return
else:
logger.info(f"No existing value for {col}")
cell_updates.append((row, col, final_value))
except Exception as e:
logger.error(f"Unable to batch {col}={final_value} due to {e}")