CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-pygsheets

tessl install tessl/pypi-pygsheets@2.0.0

Google Spreadsheets Python API v4

Agent Success

Agent success rate when using this tile

76%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.23x

Baseline

Agent success rate without this tile

62%

task.mdevals/scenario-1/

Timesheet Sync Utility

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.

Capabilities

Prepare Worksheet

  • When the worksheet is empty or has incorrect headings, write the header row ["Employee", "Hours", "Project"] starting at A1:C1 before any data rows are added. @test

Append Entries

  • Append each provided entry (ordered Employee, Hours, Project) directly after the last non-empty data row, preserving any existing rows and keeping the input entry order. @test
  • If no entries are provided, leave existing rows unchanged and avoid adding blank rows. @test

Update Totals

  • After processing entries, place a summary row immediately after the last data row with "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. @test
  • Return a result object containing rows_appended and total_hours, where total_hours matches the Hours value written in the summary row. @test

Implementation

@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}
    """

Dependencies { .dependencies }

pygsheets { .dependency }

Provides spreadsheet access for reading and writing values.

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pygsheets@2.0.x
tile.json