Once I have performed sheet = client.open_by_key('GoogleSheetKey').get_worksheet(0)
does sheet.cell(1,1)
perform another HTTP request to Google API? or is it working off a local object at that point? Thanks!
Asked
Active
Viewed 179 times
1 Answers
1
Yes, sheet.cell(1, 1)
performs another HTTP request. This is by design: gspread is a "thin" API wrapper and leaves data caching to the end user.
However, if you modifying multiple cell values, consider batching the updates with Worksheet.update_cells
method.

Burnash
- 3,181
- 2
- 31
- 35
-
How can I dynamically build `cell_list = [
, | – William B Mar 24 '17 at 14:30, | , | ]`? I am looping through JSON data that contains row number and columns to update are fixed. The only way I've found is `update_cell = sheet.cell(12,19)` then `update_cell.value = 'status1'` then `cell_list.append(update_cell)`. But this is performing HTTP request for every cell. I know where the updates belong and could build the entire `cell_list` without pinging Google. | -
At the moment the best you can do is to fetch cells in batch with `Worksheet.range`, to modify values and to batch-update the cell list. To create a Cell instance gspread needs to fetch data from API first. From your example, I can see that cells you're trying to update are not on the same row or column. What I can suggest in this case is to fetch the rectangle of cells containing your target cells with `range()`, build a map of cells with, say, coordinates tuple as a key, select the cells you need to modify and to update only selected cells with `update_cells`. – Burnash Mar 24 '17 at 18:39
-
That makes sense, thanks for following up. And thank you @Burnash for creating/supporting such a stellar Python library. As a beginner it is intuitive, well-documented contributions like yours that have made this a rewarding experience. – William B Mar 24 '17 at 19:04
-
I'm glad you find it useful. Thank you. – Burnash Mar 25 '17 at 12:05