如何从我只能查看访问谷歌合作实验室的谷歌电子表格中获取数据

发布于 2025-01-19 15:17:58 字数 1432 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖上的星空 2025-01-26 15:17:58

您应该可以通过使用 gspread 访问访问 中检索表格的内容。 。

示例:

测试表:

!pip install --upgrade -q gspread

import gspread
import pandas as pd
from google.colab import auth
from google.auth import default
auth.authenticate_user()
creds, _ = default()

gc = gspread.authorize(creds)
# sh = gc.open_by_url("Insert Sheet URL here")
sh = gc.open_by_key("Insert Sheet key here")
worksheet = sh.worksheet("Sheet1")
rows = worksheet.get_all_values()
pd.DataFrame.from_records(rows)

​ >

sstatic.net/vayvd.png“ rel =“ nofollow

  • noreferrer ” a href =“ https://docs.gspread.org/en/latest/user-guide.html#opening-a-a-spreadsheet” rel =“ nofollow noreferrer”> gspread:打开电子表格

You should be able to retrieve the content of a Sheet with View Only access in gspread by using open_by_key() or open_by_url().

Example:

Test Sheet:

enter image description here

Google Colab:

!pip install --upgrade -q gspread

import gspread
import pandas as pd
from google.colab import auth
from google.auth import default
auth.authenticate_user()
creds, _ = default()

gc = gspread.authorize(creds)
# sh = gc.open_by_url("Insert Sheet URL here")
sh = gc.open_by_key("Insert Sheet key here")
worksheet = sh.worksheet("Sheet1")
rows = worksheet.get_all_values()
pd.DataFrame.from_records(rows)

Result:

enter image description here

Reference:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文