跳转到主要内容

Google电子表格创建/更新实用工具

项目描述

作者: Pahaz Blinov

仓库: https://github.com/pahaz/google-spreadsheets-api/

简单的创建/追加Google电子表格API助手。

需求

安装

google_spreadsheet位于PyPI上,因此只需运行

pip install google_spreadsheet

easy_install google_spreadsheet

将其安装到您的环境中。

从源安装,克隆仓库并运行

python setup.py install

使用场景

在以下两个典型场景中,google_spreadsheet非常有帮助:1. 创建具有受限访问规则的新电子表格,2. 向现有电子表格追加数据。

您可以使用它将用户数据导出到Google电子表格中。并将这些数据分享到世界各地或特定用户。

使用示例

示例1:创建电子表格

from google_spreadsheet import get_credentials, Spreadsheets


def create_example():
    credentials = get_credentials('auth.json', [
        'https://www.googleapis.com/auth/drive',
        'https://www.googleapis.com/auth/spreadsheets'])
    api = Spreadsheets(credentials=credentials)
    sheet = api.create('test1', writers=['pahaz.blinov@gmail.com'])
    print(sheet)

if __name__ == '__main__':
    create_example()

示例2:向现有电子表格追加行

from google_spreadsheet import get_credentials, Spreadsheets


def append_data_example():
    credentials = get_credentials('auth.json', [
        'https://www.googleapis.com/auth/drive',
        'https://www.googleapis.com/auth/spreadsheets'])
    api = Spreadsheets(credentials=credentials)
    sheet = api.get('1jSHsmPTOOiPXdYQlrVBwbo3MO1vp64lmi5R_Ld_duKo')
    sheet.append([[1, 2], [3, 4]])


if __name__ == '__main__':
    append_data_example()

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分发

google_spreadsheet-0.0.6.tar.gz (6.1 kB 查看哈希值)

上传时间

由以下支持