我使用Google Spreadsheet API更新包含大量数据的电子表格(数百行和大约20列).
我已经测试了批量调用以更新2500个单元格.该呼叫大约需要40秒才能完成,请求大约为1mb,响应大约为2mb.
有没有办法让它更快地运作?
我使用ClientLogin方法和cURL登录google API.这工作正常,我收到一个令牌供进一步使用.我现在可以使用查询docs.google.com
$curl = curl_init();
$headers = array(
"Authorization: GoogleLogin auth=" . $auth,
"GData-Version: 3.0",
);
curl_setopt($curl, CURLOPT_URL, "https://docs.google.com/feeds/default/private/full");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
curl_close($curl);
Run Code Online (Sandbox Code Playgroud)
这工作正常,我得到了我的谷歌文档帐户中可用的所有文档的列表.但是,如果我使用从api文档中获取的URL对spreadsheets.google.com尝试相同的查询:
https://spreadsheets.google.com/feeds/spreadsheets/private/full
Run Code Online (Sandbox Code Playgroud)
我收到401错误,说明使用的令牌无效.我在两种情况下都使用相同的标记和查询.我是否需要为Google电子表格API提供不同的令牌?
编辑:这是我请求令牌的方式:
$clientlogin_url = "https://www.google.com/accounts/ClientLogin";
$clientlogin_post = array(
"accountType" => "HOSTED_OR_GOOGLE",
"Email" => "my email",
"Passwd" => "my password",
"service" => "writely",
"source" => "my application name"
);
$curl = curl_init($clientlogin_url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $clientlogin_post);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, …Run Code Online (Sandbox Code Playgroud) 关于如何使用支持的API将javascript客户端(非小工具)写入私有Google电子表格,我感到非常困惑?我没有遇到OAuth2 Drive API客户端的问题,但是没有电子表格支持!
https://developers.google.com/apis-explorer
此问题粗略地要求电子表格API显示在该页面上:
http://code.google.com/p/google-api-javascript-client/issues/detail?id=37
我可能遗漏了一些明显的东西,所以谢谢你的善意帮助我......
更新:
哇,这是踢我的背后!因此,我将尝试从Oauth2工作流中获取access_token,然后设置gdata API Authorization标头,如下所示:
service = new google.gdata.client.GoogleService('testapp');
service.setHeaders({'Authorization': 'Bearer '+ access_token});
Run Code Online (Sandbox Code Playgroud)
不幸的是,chrome控制台显示当我执行类似操作时,此标头实际上并未发送到Google
service.getFeed(url, cb, eb);
Run Code Online (Sandbox Code Playgroud)
Uffff!
我的应用代表授权用户访问私人Google电子表格文档.似乎Google的API期望开发人员首先请求授权用户可用的所有电子表格文档的列表,然后才能获得特定电子表格的密钥.我想找到一个解决方法,最后通过key从URL电子表格URL中提取参数值,如下所示:
https://docs.google.com/spreadsheet/ccc?key={some long key here}&usp=drive_web#gid=0
只需简单地将字符串分解为可以key在不需要正则表达式的情况下轻松检索其值的位置.
最近,虽然我不知道最近有多少,但我注意到新创建的Google云端硬盘电子表格的网址采用以下格式:
https://docs.google.com/spreadsheets/d/{some long key here}/edit#gid=0
我也能从这个URL字符串中提取密钥,但我只是好奇两个URL之间的区别:
谢谢!
import json
import gspread
from oauth2client.client import SignedJwtAssertionCredentials
json_key = json.load(open('Crowds-9569176f5988.json'))
scope = ['https://spreadsheets.google.com/feeds']
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope)
#gc = gspread.authorize(credentials)
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last): File "C:\Users\sony\Desktop\Python\new.py", line 8, in <module>
credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'], scope) File "C:\Python34\lib\site-packages\oauth2client\util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs) File "C:\Python34\lib\site-packages\oauth2client\client.py", line 1469, in
__init__
self.private_key = base64.b64encode(private_key) File "C:\Python34\lib\base64.py", line 62, in b64encode
encoded = binascii.b2a_base64(s)[:-1] TypeError: 'str' does not support the buffer interface
Run Code Online (Sandbox Code Playgroud)
我尝试使用编码字符串,.encode()但gspread.authorize()不支持这种类型.这是[文档] [1],显然没什么帮助.我使用的是Python …
我基本上在一张桌子上有小图像,我想在单击鼠标时放大它。我希望放大的图像显示在页面中央。再次单击鼠标以删除放大的图像。我可以使用找到的VB脚本在Excel上执行此操作,但Google表格中没有运气。有没有一种方法可以将这种脚本分配给每个图像?
亲切的问候,
亚历克斯
我一直致力于一个应用程序,我需要使用谷歌电子表格api编写和更新数据到电子表格.我已经关注了谷歌Google表格API Android快速入门提供的Android快速入门,并且能够从谷歌电子表格中检索数据,但我无法理解如何写入数据.请帮忙
我正在使用Python.我需要使用Google API v4在电子表格中添加工作表.我可以使用带有电子表格ID和addSheet请求的batchUpdate创建工作表(它返回shetId并创建空工作表).但是如何在其中添加数据?
data = {'requests': [
{
'addSheet':{
'properties':{'title': 'New sheet'}
}
}
]}
res = service.spreadsheets().batchUpdate(spreadsheetId=s_id, body=data).execute()
SHEET_ID = res['replies'][0]['addSheet']['properties']['sheetId']
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用RESTful API从Google电子表格电子表格中收集数据.
我在https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get修改了该文档,但我找不到允许我指定电子表格的特定GID(标签)的密钥.
调用API后,我能够从电子表格的第一个选项卡中获取值,但我想将其更改为第二个页面(另一个GID)
任何帮助,将不胜感激.谢谢.
编辑:添加示例:
我在这里有一个示例电子表格:https://docs.google.com/spreadsheets/d/1da3e6R08S8OoibbOgshyAQy7m9VRGPOrSGzVIvMSXf4/edit#gid=0
当我想获得A1的值时,我可以调用RESTful API:
我会得到:
{
"range": "Sheet1!A1",
"majorDimension": "ROWS",
"values": [
[
"This is on the first tab!"
]
]
}
Run Code Online (Sandbox Code Playgroud)
但正如您在我的电子表格中看到的那样,我必须使用标签(sheet2),如何获得" This is on the second tab!"的值?
嗨,我正在使用Google Colaboratory(类似于Jupyter Notebook)。有谁知道如何在此Google合作实验室笔记本中访问Google电子表格中的数据?带有链接或屏幕截图的答案,不胜感激。提前致谢!
python ×2
android ×1
curl ×1
gdata-api ×1
google-api ×1
gspread ×1
javascript ×1
php ×1
python-3.x ×1
rest ×1