Skip to content

feat: add get_all_worksheet_values to Spreadsheet#1588

Merged
antoineeripret merged 2 commits into
burnash:masterfrom
Gardner-Programs:feat/get-all-worksheet-values
Jun 16, 2026
Merged

feat: add get_all_worksheet_values to Spreadsheet#1588
antoineeripret merged 2 commits into
burnash:masterfrom
Gardner-Programs:feat/get-all-worksheet-values

Conversation

@Gardner-Programs

Copy link
Copy Markdown
Contributor

Summary

Implements #1002. Closes the feature request for fetching all worksheet values in a single API call.

This is a rewrite of #1180 against the current codebase, addressing all feedback from that review.

Changes

  • Added get_all_worksheet_values() to Spreadsheet with an optional skip_worksheet_titles parameter
  • Added extract_title_from_range() helper to utils.py with SHEET_TITLE_RE regex
  • Used absolute_range_name() to properly escape sheet titles before passing to values_batch_get
  • Regex handles all valid sheet title formats: unquoted, quoted with spaces, and titles containing apostrophes (SQL-style '' escaping)
  • Used None as default for skip_worksheet_titles to avoid mutable default argument issue raised in get_all_worksheet_values feature #1180 review

How it works

  1. Calls self.worksheets() to get all sheet titles
  2. Filters out any titles in skip_worksheet_titles
  3. Wraps each title with absolute_range_name() to handle special characters
  4. Fetches all data in one values_batch_get call
  5. Parses the response into a {sheet_title: values} dict using extract_title_from_range()
  6. Returns early with {} if all sheets are skipped (avoids an empty API call)

Tests

  • test_extract_title_from_range in utils_test.py — covers unquoted, quoted, apostrophe, and invalid input cases
  • test_get_all_worksheet_values in spreadsheet_test.py — covers normal retrieval and skip functionality via VCR cassette

Implements burnash#1002. Adds a method to fetch all worksheet values in a
single API call via values_batch_get, with an optional
skip_worksheet_titles param. Handles quoted and unquoted sheet titles
including apostrophe escaping. Includes tests for both the helper
function and the spreadsheet method.
@antoineeripret

Copy link
Copy Markdown
Collaborator

Hi @Gardner-Programs,

Thank you for the PR.

  • Could you also update the documentation before I have a look at the PR? (in this file)
  • Can you also explain how you generated the cassette file please?

Thank you !

@antoineeripret antoineeripret self-assigned this Jun 15, 2026
Adds a "Getting All Values From Every Worksheet at Once" section to the
user guide, and re-records the test cassette against the live Sheets API
(the previous cassette was synthesized with placeholder IDs).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Gardner-Programs

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

Docs: I added a "Getting All Values From Every Worksheet at Once" section to docs/user-guide.rst, following the style of the surrounding "Getting All Values…" sections.

Cassette: originally I based the cassette on the ones already saved for testing, and I missed the live recording section in CONTRIBUTING.md. Sorry about that. I've generated a new one properly using OAuth, since a service account just errors out now (Google no longer gives service accounts any storage space, so it won't let them create files and client.create() fails with storageQuotaExceeded).

@antoineeripret

Copy link
Copy Markdown
Collaborator

Thanks @Gardner-Programs :)

I've reviewed it / tested it and LGTM. I'll approve the workflow to run now and if we don't have any issue, I'll merge it.

@antoineeripret antoineeripret merged commit 6b5f244 into burnash:master Jun 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants