通过python中的api按标题查找谷歌电子表格

时间:2016-06-19 11:32:25

标签: python google-sheets google-sheets-api

我想通过按名称搜索电子表格来检索电子表格的数据。我想知道它是如何运作的?

result = service.spreadsheets().values().get(title=spreadsheetTitle, range=rangeName).execute()

2 个答案:

答案 0 :(得分:0)

通过此example,您可以按标题或网址打开电子表格。

示例:

def open(self, title):
        """Opens a spreadsheet, returning a :class:`~gspread.Spreadsheet` instance.
        :param title: A title of a spreadsheet.
        If there's more than one spreadsheet with same title the first one
        will be opened.
        :raises gspread.SpreadsheetNotFound: if no spreadsheet with
                                             specified `title` is found.
        >>> c = gspread.Client(auth=('user@example.com', 'qwertypassword'))
        >>> c.login()
        >>> c.open('My fancy spreadsheet')
        """
        feed = self.get_spreadsheets_feed()

        for elem in feed.findall(_ns('entry')):
            elem_title = elem.find(_ns('title')).text
            if elem_title.strip() == title:
                return Spreadsheet(self, elem)
        else:
            raise SpreadsheetNotFound

您还可以查看以下链接:

答案 1 :(得分:0)

您可以使用pygsheets,一个用于google sheet api v4的python库。

[Key]