我有一个google工作表,我正在根据我在python脚本中进行的一些API调用的结果来插入/更新其值。
根据gspread文档,我目前正在从工作表中获取范围,然后更新值,然后将其写回。
但我不关心工作表中的值,我宁愿盲目地写入它-节省宝贵的API读取配额。
有没有一种方法可以在不读取单元格的情况下对它们进行写入?
我在谷歌上到处寻找有同样问题的人,但我找不到任何地方告诉我如何做到这一点(或者即使我能做到)。
当前代码:
(rowData是我之前在python脚本中收集的数据,现在我希望将其写入gsheet)
try:
rowToUpdate = sheet.range("A"+str(index)+":Q"+str(index))
except Exception as e:
print("Couldn't fetch rowToUpdate, error message was: ")
print(repr(e))
try:
for cell, value in zip(rowToUpdate, rowData):
cell.value = value
sheet.update_cells(rowToUpdate)
理想情况下,我会这样做:
try:
for cell, value in zip(rowToUpdate, rowData):
cell.value = value
sheet.update_cells(rowToUpdate)```
转载请注明出处:http://www.jubohx.com/article/20230501/2080606.html