Issue with caching data uploaded via the file uploader

Hi Guys! (sorry me again, I’m on a roll with questions today! :stuck_out_tongue:)

I’m trying to upload tabular data from the file uploader.

Despite using the cache decorator @st.cache the way Andfanilo described it here, each I move anything (sliders, multi select etc…, see video below), data seems to be constantly re-uploading, which makes the app completely unsuable with any csv with a size greater than 3MB.

Here’s the Python code I’m using:

def load_data(file):
    df = pd.read_csv(file, encoding='utf-8', nrows=50)
    return df
uploaded_file = st.file_uploader("Choose a CSV file", type="csv", key='file_uploader')

I’m not sure if that’s expected - I’m pretty sure I’m doing something sub optimal here! :slight_smile:

Thanks in advance!