Add configuration, processing, and workflow modules for GoogleSheetBot
This commit is contained in:
34
workflow.py
Normal file
34
workflow.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from config import DOC_NAME, RESULT_DOC
|
||||
|
||||
def select_sheet(gsheet_api):
|
||||
"""Lists available sheets and prompts the user to select one."""
|
||||
print("📄 Pobieram listę arkuszy...")
|
||||
try:
|
||||
sheets = gsheet_api.list_sheets(DOC_NAME)
|
||||
for i, name in enumerate(sheets):
|
||||
print(f"{i+1}. {name}")
|
||||
|
||||
sheet_name = input("\nWybierz arkusz do przetworzenia: ")
|
||||
return sheet_name
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Błąd podczas pobierania listy arkuszy: {e}")
|
||||
return None
|
||||
|
||||
def get_sheet_data(gsheet_api, sheet_name):
|
||||
"""Fetches all data from a given sheet."""
|
||||
print(f"📋 Pobieram dane z arkusza: {sheet_name}")
|
||||
try:
|
||||
return gsheet_api.get_sheet_data(DOC_NAME, sheet_name)
|
||||
except Exception as e:
|
||||
print(f"❌ Błąd podczas pobierania danych z arkusza: {e}")
|
||||
return None
|
||||
|
||||
def save_results(gsheet_api, sheet_name, processed_rows):
|
||||
"""Saves the processed rows to the spreadsheet."""
|
||||
if processed_rows:
|
||||
print(f"\n\n--- Podsumowanie ---")
|
||||
print(f"Zebrano {len(processed_rows)} wierszy do przetworzenia.")
|
||||
gsheet_api.batch_append_unique_rows(RESULT_DOC, sheet_name, processed_rows)
|
||||
else:
|
||||
print("\nNie zebrano żadnych danych do przetworzenia.")
|
||||
Reference in New Issue
Block a user