I would like to share data between different user on my streamlit cloud app.
Let’s consider this example :
import streamlit as st
import pandas as pd
## User input
number_1 = st.number_input("Number 1 :",value=0)
number_2 = st.number_input("Number 2 :",value=0)
## Button to update values
# Storing data as dataframe
# Showing df
# Saving as csv
How can I tell streamlit to listen for changes to ‘my_df.csv’ and update the display, so my users can share their values with others ?
Thanks in advance !
April 18, 2023, 3:43am
Do these users have access to your app?
April 18, 2023, 7:25am
I have an app where on first load I check the time the file was last updated using pathlib.Path.stat().st_mtime and then store that in session_state as last_update_time.
I then on rerun use the same function and compare the output to last_update_time, and if different I refresh the dataframe from the updated file.
I’m sure it’s far from the most efficient way of doing this but it works.
Yes they have access, i add them with the sharing option
Good idea indeed, thanks for sharing
In my case i’m not sure it helps because if I rerun my app, it will reload the csv file, and as it is a light file, it doesn’t consume a lot of time. I just want it to be reloaded without reloading the whole code when changes are noticed.