How do I connect excel sheet to my streamlit app when deploying

I have an excel sheet on my local computer that is feeding my streamlit app. The app and every component is working fine on my local system. How do I deploy this app with the excel file that is major data point for my app?
Please assist with this urgently.

One way to deploy a Streamlit app that relies on data stored in an Excel file on your local system is to first upload the file to a cloud storage service, such as AWS S3, Azure Blob, or Google Drive. You can use required python packages along with credentials to fetch the data.

Another approach is to include the Excel file in the same working directory as the app and upload your codes and requirements to a github repository - to deploy the app and file together to a platform like Streamlit Cloud. This is the easiest and quickest way to get your app deployed and ready to share.
Read more - Deploy an app - Streamlit Docs

In any case, it is important to take security and privacy in consideration if the data is confidential.

You can use deta to store files and retrieve it when needed. Another option is to save/convert your excel file into deta database format and use it on your app.

There is a free pricing model.

I first learned deta from this guy on his yt channel. He also has some excellent videos on streamlit.

References

Deta Drive SDK
Deta Database SDK

2 Likes

Thank you for this reply, I have tried to put the excel file in the same file as my app and deploy together. It’s working on my system, but I get a ‘FileNotFoundError’ when the app is deployed.
Find below the error I get from the streamlit app log. Kindly help review and advised on how I can get past this.

2023-01-12 10:35:16.038 Uncaught app exception
Traceback (most recent call last):
  File "/home/appuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 565, in _run_script
    exec(code, module.__dict__)
  File "/app/avon-wellness-survey/WellnessApp.py", line 12, in <module>
    wellness_df = pd.read_csv(path)
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/util/_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/util/_decorators.py", line 331, in wrapper
    return func(*args, **kwargs)
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 950, in read_csv
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 605, in _read
  File "/home/appuser/venv/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1442, in __init__

Seems like you’re putting the absolute path inside your code. This will not work as you deploy the app since it is not running on your system anymore.

Just use the relative path, like data/mydata.csv where data is the folder in your main app directory and inside the folder the csv file is present. If there’s no such folder structure needed, simply mentioning the filename will do the trick.

Hope this helps! :balloon:

Thank you, yes it did. I have my app running now. :+1:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.