Skip to content

Added set_records and set_record to update sheet via records.[Issue #677]#1494

Open
muddi900 wants to merge 26 commits into
burnash:masterfrom
muddi900:add/set-records
Open

Added set_records and set_record to update sheet via records.[Issue #677]#1494
muddi900 wants to merge 26 commits into
burnash:masterfrom
muddi900:add/set-records

Conversation

@muddi900
Copy link
Copy Markdown
Contributor

@muddi900 muddi900 commented Jul 21, 2024

Fixes #677

@alifeee
Copy link
Copy Markdown
Collaborator

alifeee commented Jul 23, 2024

thanks for the implementation!

I find the test hard to parse, would it be possible to write it with very explicit objects? e.g.,

table_before = [
  ["header 1", "header 2"]
  ["value 1",  "value 2"]
]
table_after = [
  ["header 1",    "header 2"]
  ["value 1",     "value 2"]
  ["new value 1", "new value 2"]
]

Comment thread tests/worksheet_test.py Outdated
Comment thread gspread/worksheet.py Outdated
Comment thread gspread/worksheet.py Outdated
Comment thread gspread/worksheet.py Outdated
darkfiberiru pushed a commit to darkfiberiru/gspread that referenced this pull request Nov 25, 2025
… sheet via records

This PR adds methods to update spreadsheet data using dictionary-based records
with column headers, addressing feature request burnash#677.

New methods added:
- set_records() - Sets multiple rows of data using records
- set_record() - Sets a single row of data using a record
- append_records() / append_record() - Appends records to the sheet
- insert_records() / insert_record() - Inserts records at specific positions
- get_column_headers() - Retrieves column headers from the first row

Key features:
- Enables intuitive, record-based data format (dict mapping headers to values)
- Leverages existing functionality like append_rows() and insert_rows()
- Includes comprehensive tests with explicit test values
- Supports parameter handling for missing/extra headers

Status: Safe to merge - adds new functionality without modifying existing APIs
darkfiberiru pushed a commit to darkfiberiru/gspread that referenced this pull request Nov 25, 2025
- Remove @pytest.mark.vcr() decorator from reset_sheet fixture
  (fixes pytest deprecation warning about marks on fixtures)
- Include cassettes for PR burnash#1494 tests (append_records, insert_records)

The cassettes were already included in the merged PRs and are required
for offline testing of the new record-based methods.
darkfiberiru pushed a commit to darkfiberiru/gspread that referenced this pull request Nov 25, 2025
- Remove @pytest.mark.vcr() decorator from reset_sheet fixture
  Pytest 9.0 warns that marks applied to fixtures have no effect.
  Marks only work on test functions, not fixtures. The reset_sheet
  fixture just clears the sheet between tests and doesn't need VCR
  recording. Individual test methods already have their own VCR marks.

- Include cassettes for PR burnash#1494 tests (append_records, insert_records)
  The cassettes were already included in the merged PRs and are required
  for offline testing of the new record-based methods.
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.

Feature Request: set_record + set_records

3 participants