Refactor main function to improve sheet selection process and error handling
This commit is contained in:
20
main.py
20
main.py
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user