我想通过它的API将数据从这里写入Google表格(http://acleddata.com/api/acled/read)。我使用gspread包来提供帮助。写入谷歌电子表格API非常慢
下面是代码:
r = requests.get("http://acleddata.com/api/acled/read")
data = r.json()
data = data['data']
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
gc = gspread.authorize(credentials)
for row in data:
sheet.append_row(row.values())
的数据是字典的列表,每个字典表示在电子表格中的行。这是写给我的Google表格,但速度慢得不可思议。花了40分钟写了一百行,然后我打断了剧本。
我能做些什么来加速这个过程吗?
谢谢!
感谢您的回复。我检查了这一点。与此同时,我想出了什么可能是主要原因 - 使用append_row方法每次调用api时都会调用它。我张贴在下面找到的修复 – Aschharwood