Skip to content

Instantly share code, notes, and snippets.

@maksam07
Created June 20, 2023 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maksam07/a517ca31352e7688c896c2597f2ca4da to your computer and use it in GitHub Desktop.
Save maksam07/a517ca31352e7688c896c2597f2ca4da to your computer and use it in GitHub Desktop.
pygsheets 2.0.6. Updating multiple cells with a single request. Data in dictionary format "address: value"
def update_values_batch_dict(ws, data):
keys = list(data.keys())
values = [[[val]] for val in data.values()]
return ws.update_values_batch(keys, values)
gc = pygsheets.authorize()
sh = gc.open_by_key('***')
ws = sh.worksheet_by_title('***')
cells = {
'A1': '1',
'A2': '2',
'A3': '3',
'B1': '11',
'B2': '22',
'B3': '33',
}
update_values_batch_dict(ws, cells)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment