在电子表格上添加行的用户配额超过100秒 [英] Adding rows on a spreadsheet exceeds 100 sec user quota

查看:98
本文介绍了在电子表格上添加行的用户配额超过100秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用Python编写脚本,以使用gspread在电子表格中添加行.

I am writing a script in Python to add rows into a spreadsheet using gspread.

client = gspread.authorize(creds)
ws = client.open("my spreadsheet").sheet1
...

for xml in for xml in soup.findAll('items'):
  item = {
      ...
  }
  ws.append_row(item)

这项工作直到我收到大约100件商品,然后它给我一个错误

This work until I reach around 100 items and then it gives me an error

错误":{
代码":429,
"message":配额'WriteGroup'的令牌不足,并且消费者'project_number:644051582230'的服务'sheets.googleapis.com'的'USER-100s'数量受到限制.",
状态":"RESOURCE_EXHAUSTED"

"error": {
"code": 429,
"message": "Insufficient tokens for quota 'WriteGroup' and limit 'USER-100s' of service 'sheets.googleapis.com' for consumer 'project_number:644051582230'.",
"status": "RESOURCE_EXHAUSTED"

有任何关于如何以不同方式编写此代码以避免出现许多请求或避免出现此配额限制错误的想法吗?

Any ideas on how to write this in a different way to avoid that many requests or a way of not getting this quota limit error?

推荐答案

column_names= ['','A','B','C','D','E','F','G','H']
cell_range = 'A1:' + str(column_names[len(items_list[0])]) + str(len(items_list))
cells = sheet.range(cell_range)
flattened_data = []

for x in items_list:
 for y in x:
  flattened_data.append(y)


for x in range(len(flattened_data)):
   cells[x].value = flattened_data[x].decode('utf-8')

sheet.insert_row(title, index=1)

这对我有用,这要感谢roganshosh对我的问题的评论

That worked for me, thanks to roganshosh's comments to my question

这篇关于在电子表格上添加行的用户配额超过100秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆