Google Spreadsheets Python API v4
76
Design a utility that keeps a spreadsheet worksheet in sync with incoming time-entry records by reading existing rows, appending new data, and refreshing a summary row. Use the provided sheets client to open the spreadsheet by id and target the worksheet matching the given title; all table data begins at cell A1.
["Employee", "Hours", "Project"] starting at A1:C1 before any data rows are added. @test"TOTAL" in the first column and the numeric sum of the Hours column in the second column, replacing any previous summary row and ignoring header or old summary rows when calculating the total. @testrows_appended and total_hours, where total_hours matches the Hours value written in the summary row. @test@generates
from typing import Any, Dict, List
def sync_timesheet(sheets_client: Any, spreadsheet_id: str, worksheet_title: str, entries: List[Dict[str, Any]]) -> Dict[str, Any]:
"""
entries: list of records with Employee (str), Hours (number), and Project (str)
returns: {"rows_appended": int, "total_hours": float}
"""Provides spreadsheet access for reading and writing values.
Install with Tessl CLI
npx tessl i tessl/pypi-pygsheetsdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10