Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.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
Python 如何将数据导出到google工作表_Python_Google Sheets_Automation - Fatal编程技术网

Python 如何将数据导出到google工作表

Python 如何将数据导出到google工作表,python,google-sheets,automation,Python,Google Sheets,Automation,嘿,伙计们,我做了一个抓取程序,从网站上抓取一些信息,现在我需要把这些信息放到谷歌的表格中,我想知道什么是最好的方法?要将其转换为csv文件,然后将其放入工作表中?或者其他任何我愿意接受的建议。使用是更好的方法,这样可以避免资源密集型文件读/写操作 Pre-req:创建一个服务帐户并将密钥json放在手边,下面是python中的示例代码: import gspread from oauth2client.service_account import ServiceAccountCredentia

嘿,伙计们,我做了一个抓取程序,从网站上抓取一些信息,现在我需要把这些信息放到谷歌的表格中,我想知道什么是最好的方法?要将其转换为csv文件,然后将其放入工作表中?或者其他任何我愿意接受的建议。

使用是更好的方法,这样可以避免资源密集型文件读/写操作

Pre-req:创建一个服务帐户并将密钥json放在手边,下面是python中的示例代码:

import gspread
from oauth2client.service_account import ServiceAccountCredentials
import datetime

SCOPE = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']
SAMPLE_SPREADSHEET_ID = 'xxxxxx'

def update_cell(cell, value):
credentials = ServiceAccountCredentials.from_json_keyfile_name('downloaded.json', SCOPE)
gc = gspread.authorize(credentials)

wks = gc.open_by_key(SAMPLE_SPREADSHEET_ID).get_worksheet(1)
wks.update_acell(cell, value)

if __name__ == '__main__':
    update_cell('A1', 'test')

发布google工作表,您可以像访问任何其他RESTAPI一样访问它

请勾选此项以供参考:


首先,在开始阅读文档时,是否要创建新工作表或更新现有工作表?您的数据的类型和结构是什么?当我这样做时,pylint在凭证行上说无效语法会出现错误,对此我能做些什么?我试着用谷歌搜索它,但找不到适合我的asnwerWorks(python2.7)你能发布你的错误吗