Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets 如何使用google colab阅读google电子表格_Google Sheets_Google Sheets Api_Google Colaboratory_Flysystem Google Drive - Fatal编程技术网

Google sheets 如何使用google colab阅读google电子表格

Google sheets 如何使用google colab阅读google电子表格,google-sheets,google-sheets-api,google-colaboratory,flysystem-google-drive,Google Sheets,Google Sheets Api,Google Colaboratory,Flysystem Google Drive,我们可以使用下面的命令列出GoogleDrive中的电子表格 from google.colab import drive drive.mount('/content/drive') !ls -l /content/drive/'Shared drives' 但无法使用以下命令读取电子表格 import gspread from oauth2client.client import GoogleCredentials gc = gspread.authorize(GoogleCrede

我们可以使用下面的命令列出GoogleDrive中的电子表格

 from google.colab import drive
 drive.mount('/content/drive')
 !ls -l /content/drive/'Shared drives'
但无法使用以下命令读取电子表格

import gspread
from oauth2client.client import GoogleCredentials

gc = gspread.authorize(GoogleCredentials.get_application_default())

gc.open('/content/drive/'Shared drives/data.gsheet').data available
还有一个问题,sheetname中有空格(数据可用),无法更改sheetname

我有参考链接::

请提供帮助。

如果您能说出运行此脚本时出现的确切错误,那将非常有用。但是,我注意到下面的脚本中有多余的引号

gc.open('/content/drive/'Shared drives/data.gsheet'))

将上述额外部分替换为以下内容:

gc.open(“/content/drive/Shared drives/data.gsheet”)


另一个选项是尝试使用gc.open_by_url()而不是gc.open()

您可以使用
gc.open_by_url('gsheets_url')
打开文档(无需安装驱动器)。对于工作表名称,可以使用
gsheets.worksheet('sheet name')

所以在你的情况下,它会是这样的:

从google.colab导入验证
auth.authenticate_user()
进口gspread
从oauth2client.client导入Google凭据
#设置
gc=gspread.authorize(GoogleCredentials.get\u application\u default())
#读取数据并将其放入数据框中
gsheets=gc.openbyurl('your-link'))
sheets=gsheets.worksheet('data available')。获取所有值()
df=pd.DataFrame(表[1:],列=表[0])
(贷记到)

提供。具体来说,请描述问题。“它不起作用”不足以帮助人们理解你的问题。相反,告诉其他读者预期的行为应该是什么。告诉其他读者错误消息的确切措辞,以及产生错误消息的代码行。用简短但描述性的问题摘要作为问题的标题。