0

I have a small business requirement to build a dashboard and I was searching for some solutions where I came across streamlit using python. Since am new to streamlit I need to know whether below options are possible before I start building webapp.

  1. Master account to login and access the dashboard
  2. connecting to google sheets to read and update the data (adding new rows and columns or editing the existing one)

any reference link for my requirement is really helpful. Thank you in advance

Still looking for ways to create dashboard for my requirements

Varun G
  • 11
  • 3

1 Answers1

0

I tried with the documentation gsheetsdb but it gave me issues related to updating the values. That's why I explored gspread library instead and worked for me and its easier than the one in the documentation. (personal opinion) The json file in the code can be obtained the same way it is given in the documentation.

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)

Check documentation here to get the json file: streamlit docs

Note: In the JSON file, there will be a service account email id. You need to copy that and put it in the Excel sheet Share option. Click on Share and then add a service account email shown below

enter image description here