例外:范围超出网格限制。最大行数:1001,最大列数:20“,\ n”状态“:” INVALID_ARGUMENT“

时间:2019-04-21 07:26:56

标签: python spreadsheet discord gspread

所以我要制造一个不和谐的机器人,该机器人从Spreadsheet中提取数据以执行检查。

async def fetch_sheet():
    await bot.wait_until_ready()
    global list_of_lists
    i = 0
    while True:
        #if creds.access_token_expired:
        client.login()  # refreshes the token
        list_of_lists = client.open('Guild Roster 2').worksheet("ViP1").get_all_values()
        print("ViP Worksheet Access: Stable")
        i += 1
        print ('Sheet Fetch Count: {0}'.format(i))
        await asyncio.sleep(60)

运行此命令时,出现异常消息,提示我已超出最大网格限制。任何想法如何解决这个问题?我在某处读到它是因为其他工作表的名称,我什至更改了它,但问题仍然存在:

2019-04-21T07:16:12.347017+00:00 app[bot.1]: Task exception was never retrieved
2019-04-21T07:16:12.347060+00:00 app[bot.1]: future: <Task finished coro=<fetch_sheet() done, defined at main.py:63> exception=APIError('{\n  "error": {\n    "code": 400,\n    "message": "Range (\'ViP1\'!VIP1) exceeds grid limits. Max rows: 1001, max columns: 20",\n    "status": "INVALID_ARGUMENT"\n  }\n}\n',)>
2019-04-21T07:16:12.347062+00:00 app[bot.1]: Traceback (most recent call last):
2019-04-21T07:16:12.347063+00:00 app[bot.1]:   File "main.py", line 70, in fetch_sheet
2019-04-21T07:16:12.347064+00:00 app[bot.1]:     list_of_lists = client.open('Guild Roster 2').worksheet("ViP1").get_all_values()
2019-04-21T07:16:12.347066+00:00 app[bot.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gspread/models.py", line 444, in get_all_values
2019-04-21T07:16:12.347068+00:00 app[bot.1]:     data = self.spreadsheet.values_get(self.title)
2019-04-21T07:16:12.347069+00:00 app[bot.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gspread/models.py", line 110, in values_get
2019-04-21T07:16:12.347070+00:00 app[bot.1]:     r = self.client.request('get', url, params=params)
2019-04-21T07:16:12.347071+00:00 app[bot.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/gspread/client.py", line 79, in request
2019-04-21T07:16:12.347073+00:00 app[bot.1]:     raise APIError(response)
2019-04-21T07:16:12.347074+00:00 app[bot.1]: gspread.exceptions.APIError: {
2019-04-21T07:16:12.347075+00:00 app[bot.1]:   "error": {
2019-04-21T07:16:12.347077+00:00 app[bot.1]:     "code": 400,
2019-04-21T07:16:12.347078+00:00 app[bot.1]:     "message": "Range ('ViP1'!VIP1) exceeds grid limits. Max rows: 1001, max columns: 20",
2019-04-21T07:16:12.347079+00:00 app[bot.1]:     "status": "INVALID_ARGUMENT"
2019-04-21T07:16:12.347080+00:00 app[bot.1]:   }
2019-04-21T07:16:12.347082+00:00 app[bot.1]: }

我想将数据提取到工作表中并将其存储在“ list_of_lists”变量中,以进一步使用该数据执行不同的命令。

1 个答案:

答案 0 :(得分:0)

真的不知道为什么,但是在工作表名称的某处添加下划线对我有用。尝试将“ ViP1”重命名为“ ViP_1”