Refactor main function to improve sheet selection process and error handling

This commit is contained in:
2025-10-29 21:31:09 +01:00
parent fd75bc88dc
commit 5f00e63f71

20
main.py
View File

@@ -111,20 +111,28 @@ def process_row(row, mayo, counter):
print(f"❌ Błąd podczas przetwarzania linku {link}: {e}")
return None
def main():
# Inicjalizuj API raz na początku
gsheet_api = GSheetAPI()
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
return None
sheet_name = input("\nWybierz arkusz do przetworzenia: ")
def main():
# Inicjalizuj API raz na początku
gsheet_api = GSheetAPI()
sheet_name = select_sheet(gsheet_api)
if not sheet_name:
return
print(f"📋 Pobieram dane z arkusza: {sheet_name}")
try: