【发布时间】:2021-09-16 06:19:04
【问题描述】:
我正在尝试将此 CSV 文件附加到此 Google 表格中的最后一行数据之后。但我只能覆盖现有数据。
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ["https://spreadsheets.google.com/feeds", 'https://www.googleapis.com/auth/spreadsheets',
"https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"]
credentials = ServiceAccountCredentials.from_json_keyfile_name(
'key.json', scope)
client = gspread.authorize(credentials)
spreadsheet = client.open('upload_data')
with open('gmt2.csv', 'r') as file_obj:
content = file_obj.read()
client.import_csv(spreadsheet.id, data=content)
【问题讨论】:
标签: python google-sheets google-sheets-api gspread