简体   繁体   English

如何使用链接从python上的Google电子表格获取数据

[英]how to get data from google spread sheet on python using link

I want to read data in google spreadsheet using python. 我想使用python读取Google电子表格中的数据。

I have a spreadsheet link. 我有一个电子表格链接。

I don't want to using oauth2client. 我不想使用oauth2client。 Because only read what I want to. 因为只读我想要的。 not write. 别写。

Is there a way I can do? 有办法吗?

  1. you can't do it without using oauth. 不使用oauth就无法做到。
  2. there's a good library called gspread - check it out. 有一个很好的库叫做gspread-签出来。
  3. Running oauth is as simple as the following code example (you should, first, create a google developer account and get your private key etc 运行oauth就像下面的代码示例一样简单(首先,您应该创建一个Google开发者帐户并获取您的私钥,等等)
  4. See the following code example (that uses gspread) 请参见以下代码示例(使用gspread)

from oauth2client.client import SignedJwtAssertionCredentials

def authenticate_and_get_spreadsheet():
    scope = ['https://spreadsheets.google.com/feeds']
    client_email = get_client_email() # something that looks like 962835581947-l1r8s2brhu5sjfljkg7ve54fcfxuio2b@developer.gserviceaccount.com
    private_key = get_private_key()
    credentials = SignedJwtAssertionCredentials(client_email, private_key, scope)
    gc = gspread.authorize(credentials)
    return gc


def get_spreadsheet():
    gc = authenticate_and_get_spreadsheet()
    ss = gc.open_by_key('1FxDkjsdhffQOPC-f93Cccebkjasd5NMzl4AahDk')  # document key
    return ss # now you can read/write this spreadsheet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从python中的谷歌电子表格下载原始数据 - How to download raw data from google spread sheet in python Python:Google Spread Sheet API:如何设计在Google Sheet中存储用户数据? - Python: Google Spread Sheet API: How to design storing users data in Google Sheet? 如何使用Python重命名电子表格中的工作表名称? - How to rename the sheet name in the spread-sheet using Python? 如何使用python GSPREAD找到谷歌电子表格的第一行空行? - How to find the first empty row of a google spread sheet using python GSPREAD? 如何使用 Python 将 Google 表单链接到 Google 表格? - How to link a Google Form to a Google Sheet using Python? 将谷歌电子表格分享给 Python 中的每个人 - share google spread sheet to everyone in python 使用gspread将数据追加到Google SpreadSheet - Appending data on to a Google Spread-Sheet with gspread 如何将 Excel 工作表中的数据放入具有多个参数的 API 链接并使用 Python 下载 PDF? - How to put data from an Excel sheet into an API link with multiple parameters and download the PDF using Python? Python 从 URL 获取数据并在 Google 表格中写入不适用于 heroku? - Python get data from URL and write in Google sheet not working on heroku? 如何通过 Google Spread Sheet 进行搜索 - How to search thru Google Spread Sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM