我有一个构建仪表板的小业务需求,我正在寻找一些解决方案,在这些解决方案中我遇到了使用 python 的 streamlit。由于我是 streamlit 的新手,所以在开始构建 webapp 之前,我需要知道以下选项是否可行。
满足我要求的任何参考链接都非常有帮助。提前谢谢你
仍在寻找根据我的要求创建仪表板的方法
我尝试使用 gsheetsdb 文档,但它给了我与更新值相关的问题。这就是为什么我改为探索 gspread 库并为我工作的原因,它比文档中的库更容易。 (个人想法) 代码中的json文件可以按照文档中给出的方式获取。
import gspread
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']
#the json file should be put in the same location as the python file or give the entire path.
creds = ServiceAccountCredentials.from_json_keyfile_name('testingdb-b6d4d-d0a2646c069a.json', scope)
client = gspread.authorize(creds)
#Create one workbook name it 'TestSheet' and at the bottom rename Sheet1 as 'names'
sh = client.open('TestSheet').worksheet('names')
#Create a list the way you want and add the data to excel worksheet,
#just use the append_row function of the sh object created.
#To read all the data just use the read_all_values() function and you get a list of lists.
row = ["Jason","22","Photography"]
sh.append_row(row)
在此处查看文档以获取 json 文件:streamlit docs
注意:在 JSON 文件中,会有一个服务帐户电子邮件 ID。您需要复制它并将其放入 Excel 工作表共享选项中。单击共享,然后添加如下所示的服务帐户电子邮件