Refactor select_sheet function to automatically generate sheet names based on the current month and year
This commit is contained in:
2
main.py
2
main.py
@@ -7,7 +7,7 @@ from processing import process_all_rows
|
||||
def main():
|
||||
gsheet_api = GSheetAPI()
|
||||
|
||||
sheet_name = select_sheet(gsheet_api)
|
||||
sheet_name = select_sheet()
|
||||
if not sheet_name:
|
||||
return
|
||||
|
||||
|
||||
21
workflow.py
21
workflow.py
@@ -1,19 +1,12 @@
|
||||
import datetime
|
||||
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 select_sheet():
|
||||
"""Generates the sheet name based on the current month and year (MM.YYYY)."""
|
||||
now = datetime.datetime.now()
|
||||
sheet_name = now.strftime("%m.%Y")
|
||||
print(f"📄 Automatycznie wybrano arkusz: {sheet_name}")
|
||||
return sheet_name
|
||||
|
||||
def get_sheet_data(gsheet_api, sheet_name):
|
||||
"""Fetches all data from a given sheet."""
|
||||
|
||||
Reference in New Issue
Block a user