google-sheets - Gspread Quota 超出配额指标“读取请求”和限制“每个用户每分钟读取请求”
问题描述
cell_matrix = []
init_colnum=colnum
init_rownum=rownum
worksheet = sheet.worksheet(sheet_name)
if resize:
worksheet.add_rows(df.shape[0]+init_colnum)
worksheet.add_cols(df.shape[1]+init_rownum)
t_all=0
t1 = time.time()
i=1
for index,row in df.iterrows():
print(rownum)
if creds.access_token_expired:
client.login() # refreshes the token
if i%50==0:
worksheet.update_cells(cell_matrix)
cell_matrix = []
reauthorize()
#time.sleep(120)
if creds.access_token_expired:
client.login() # refreshes the token
cellrange = '{start_col}{row}:{last_col}{row}'.format(row=rownum, start_col=get_colname_using_index(colnum), last_col=get_colname_using_index(colnum+len(row)-1))
# get the row from the worksheet
cell_list = worksheet.range(cellrange)
columnnumber = 0
for cell in row:
if pd.isnull(cell):
cell_list[columnnumber].value = ''
else:
cell_list[columnnumber].value = cell
columnnumber += 1
# add the cell_list, which represents all cells in a row to the full matrix
cell_matrix = cell_matrix + cell_list
t_all += (time.time() - t1)
t1 = time.time()
#sys.stdout.write("\rrownum: {}, rows: {}; avg time: {} secs; Total time: {} secs".format(rownum, i, t_all/i, t_all))
#sys.stdout.flush()
rownum += 1
i+=1
# output the full matrix all at once to the worksheet.
worksheet.update_cells(cell_matrix)
if resize:
worksheet.resize(df.shape[0]+init_rownum-1, df.shape[1]+init_colnum-1)
上面的代码抛出以下错误:gspread.exceptions.APIError: {u'status': u'RESOURCE_EXHAUSTED', u'message': u"配额指标“读取请求”和限制“每个用户每分钟读取请求”的配额超出'消费者'project_number:1044022051760'的服务'sheets.googleapis.com'。", u'code': 429, u'details': [{u'reason': u'RATE_LIMIT_EXCEEDED', u'@type': u'type.googleapis.com/google.rpc.ErrorInfo', u'domain': u'googleapis.com', u'metadata': {u'quota_metric': u'sheets.googleapis.com/read_requests', u '消费者':u'projects/1044022051760',u'service':u'sheets.googleapis.com',u'quota_limit':u'ReadRequestsPerMinutePerUser'}}]}
解决方案
推荐阅读
- javascript - ValidationError: validTill: Cast to Number 路径 \"validTill\" 的值 \"NaN\" 失败
- node.js - 如何在猫鼬中加入两个集合
- javascript - Nightwatch 在测试中忽略等待
- python - 更新 str 类继承的对象的值
- python-3.x - Sentry SDK Django 为事件和引发设置标签
- php - 尝试“写入”pdf文件(PDFLIB)时出现权限错误?
- bash - bash中一个字符串中的多个正则表达式匹配
- vba - 选择。保存文档Word的文本问题
- php - 从 Twinfield API 获取未经授权的客户端
- javascript - 我制作了一个虚拟键盘,当我从键盘(数字)检查显示值时,它是未定义的......我如何获得一个数字作为值?