我想通過它的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