feat: add get_all_worksheet_values to Spreadsheet#1588
Conversation
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.
|
Thank you for the PR.
Thank you ! |
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>
|
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). |
|
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. |
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
get_all_worksheet_values()toSpreadsheetwith an optionalskip_worksheet_titlesparameterextract_title_from_range()helper toutils.pywithSHEET_TITLE_REregexabsolute_range_name()to properly escape sheet titles before passing tovalues_batch_get''escaping)Noneas default forskip_worksheet_titlesto avoid mutable default argument issue raised in get_all_worksheet_values feature #1180 reviewHow it works
self.worksheets()to get all sheet titlesskip_worksheet_titlesabsolute_range_name()to handle special charactersvalues_batch_getcall{sheet_title: values}dict usingextract_title_from_range(){}if all sheets are skipped (avoids an empty API call)Tests
test_extract_title_from_rangeinutils_test.py— covers unquoted, quoted, apostrophe, and invalid input casestest_get_all_worksheet_valuesinspreadsheet_test.py— covers normal retrieval and skip functionality via VCR cassette