我正在使用http://pygsheets.readthedocs.io/en/latest/index.html google sheet api v4 的包装器。
我有一个小脚本,我试图选择一个 json 表上传到谷歌表工作表。文件名由以下部分组成:
spreadsheetname_year_month_xxx.json
编码:
import tkinter as tk
import tkFileDialog
import pygsheets
root = tk.Tk()
root.withdraw()
file_path = tkFileDialog.askopenfilename()
print file_path
file_name = file_path.split('/')[-1]
print file_name
file_name_segments = file_name.split('_')
spreadsheet = file_name_segments[0]
worksheet = file_name_segments[1]+'_'+file_name_segments[2]
gc = pygsheets.authorize(outh_file='client_secret_xxxxxx.apps.googleusercontent.com.json')
ssheet = gc.open(spreadsheet)
ws = ssheet.add_worksheet(worksheet(ssheet,str(raw_input(file_path))))
文件路径导致生成的 json 文件如下所示:
{
"count": 12,
"results": [
{
"case": "abc1",
"case_name": "invalid",
"case_type": "invalid",
},
{
"case": "abc2",
"case_name": "invalid",
"case_type": "invalid",
},
............
我正进入(状态 :
File "upload_to_google_sheets.py", line 27, in <module>
ws = ssheet.add_worksheet(worksheet(ssheet,str(raw_input(file_path))))
TypeError: 'unicode' object is not callable
如您所见,我正在尝试使用 json 数据实例化工作表。我究竟做错了什么?