I'm learning how to use Google Sheet API and Python.
Firstly, I need to update specific cells in Google Sheet, not a range of cells.
I could use update_cell(), but each update will take up a Write Request, which is not optimal.
sheet_ELCSV.update_cell(str(x),1,OH_row_Side)
sheet_ELCSV.update_cell(str(x),str(PairA_Idx),str(OH_row_Executed))
sheet_ELCSV.update_cell(str(x+1),1,"Fee")
sheet_ELCSV.update_cell(str(x+1),11,str(Sum_Fee))
I read the developers guide on spreadsheets().values().update() and batchUpdate. If I'm not mistaken, they only take 1 write request. But I don't get how to do specific cells update.
ssName = sheet_ELCSV.title + '!'
cell_range = 'A2,B2,D2,A3,K3'
values = (
('Sell','-2.17','27760.0476'),
('Fee', '-2.38285229')
)
value_range = {
'majorDimension' : 'ROWS',
'values': values
}
service.spreadsheets().values().update(
spreadsheetId = ssID,
valueInputOption = 'USER_ENTERED',
range = ssName + cell_range,
body = value_range
).execute()
Any guidance is appreciated!
