Python Forum
Python + Google Sheet | Best way to update specific cells in a single Update()?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python + Google Sheet | Best way to update specific cells in a single Update()?
#2
Good day!

The below codes serve to update one or many cells in Google Sheet.
Between the two codes below, which would be most effective in using the least Write Request?
This is to minimize the Usage Limit for calling Google Sheet API.
I assume that if TH_MatchedRows = 3, then Code 1 will have 3 Requests, while Code 2 will always have 1 request regardless of TH_MatchedRows size.
Correct me if I'm wrong.

for i in TH_MatchedRows:
        sheet_THCSV.update_cell(i,9,OH_CurRow) 
OR

 TempList = []
 for i in TH_MatchedRows:
    TempList.append(OH_CurRow)

ssName = sheet_THCSV.title + '!'
cell_range = 'I' + str(TH_MatchedRows[-1]) + ':I' + str(TH_MatchedRows[0])
values = TempList
value_range = {
    'majorDimension' : 'COLUMNS',
    'values': [values]
}
service.spreadsheets().values().update(
    spreadsheetId = ssID,
    valueInputOption = 'USER_ENTERED',
    range = ssName + cell_range,
    body = value_range
).execute()
Tyvm
Reply


Messages In This Thread
Google Sheet | update_cell() vs spreadsheets().values().update() - by Vokofe - Dec-16-2020, 05:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Sad Selenium update broke python code genericusername12414 1 214 Mar-16-2024, 07:33 PM
Last Post: snippsat
  Python and pandas: Aggregate lines form Excel sheet Glyxbringer 12 1,828 Oct-31-2023, 10:21 AM
Last Post: Pedroski55
Question Using SQLAlchemy, prevent SQLite3 table update by multiple program instances Calab 3 740 Aug-09-2023, 05:51 PM
Last Post: Calab
  [notice] A new release of pip available: 22.3.1 -> 23.1.2 [notice] To update, run: C: GoldenHarvey 3 5,188 Jun-06-2023, 05:43 PM
Last Post: GoldenHarvey
  Error 1064 (42000) when executing UPDATE SQL gratiszzzz 7 1,442 May-22-2023, 02:38 PM
Last Post: buran
  class Update input (Gpio pin raspberry pi) caslor 2 784 Jan-30-2023, 08:05 PM
Last Post: caslor
  How to read csv file update matplotlib column chart regularly SamLiu 2 1,053 Jan-21-2023, 11:33 PM
Last Post: SamLiu
  cannot update PIP tester_V 1 712 Jan-12-2023, 07:17 AM
Last Post: tester_V
  Priority Queue with update functionality PythonNewbee 4 1,895 Dec-29-2022, 12:13 PM
Last Post: Yoriz
  (Python) Pulling data from UA Google Analytics with more than 100k rows into csv. Stockers 0 1,204 Dec-19-2022, 11:11 PM
Last Post: Stockers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020