Search code examples
pythongoogle-sheets-apigspread

Gspread update value without getting it first / addition to cell directly


Currently using gspread and python. Currently to update values on my spreadsheet I have to grab values from sheet, update them and then write back.

What i am looking for is...say I have a cell with a value of 5, is there a way to make an api call that says add +5 to "x" cell? I would no longer need to grab the values first, which even saves an api call. I don't know if this command is available or anything similar is, but would appreciate any help here!


Solution

  • Poring over both the documentation for gspread and the Sheets API I'm fairly confident that this cannot be done. All the methods that update values on a sheet require you to specify a range and the list of values, but you are unable to refer to the current values within the range without first retrieving them.

    Your best way to reduce API calls is to just retrieve and update the data in batches as much as possible using batch_get() and batch_update().

    If you'd like to submit feedback to Google to implement something like this in a future API update you can check out their issue tracker.