我正在创建一个脚本,使用python库gspread将CSV文件上传到Google电子表格。我无法使用gspread的.service_account()
身份验证向gspread进行身份验证来请求我的电子表格。任何帮助将不胜感激。我的代码在下面。
import gspread
#UPLOAD CSV START
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"]
print("some text here to see if the code up to this point is running")
client = gspread.service_account(filename="you google sheets credentials .json here")
print("some text here to see if the code up to this point is running")
spreadsheet = client.open('Products')
print("some text here to see if the code up to this point is running")
with open('data.csv', 'r') as file_obj:
content = file_obj.read()
client.import_csv(spreadsheet.id, data=content)
print("some text here to see if the code up to this point is running")
#UPLOAD CSV END
非常感谢您的帮助