Save a stocks watchlist to csv at a local directory and reload it from there

Hi to all
I have a small watchlist of stocks as a st.data_editor that i want to modify and save as a csv at a local directory at the end of every day and then reload it from there the next day when i restart my streamlit app.
I only need the part of the code or function that saves the table to csv to any assigned directory with a button or something similar.
Can someone help me to do this.
Many Thanks in advance!

watchlist = {
“Long Bottom”: [‘AAPL’],
“Long Bottom Sqz”: [‘GOOG’],
“Short Top” : [‘INTC’],
“Short Top Sqz” : [‘NFLX’],
“Continuation Long”: [‘GM’],
“Continuation Short”: [‘DIS’],

stox_list = pd.DataFrame(watchlist)

Hi ! You can refer this code below if maybe helpful.

import streamlit as st
import pandas as pd

df = pd.read_csv("dir/file.csv")

def convert_df(df):
   return df.to_csv(index=False).encode('utf-8')

csv = convert_df(df)

   "Press to Download",

use .to_csv insted to excel
if you want your data to be exported into pure excel format then consider using other python lib like


Any question ? plz be free to ask

Thanks a lot…i ll try the code and let you know asap!

Hi again…the code just writes the existing data frame to csv…the point is to edit the data frame with st.editor in my streamlit app and then update/rewrite the file in the directory so that next time i run the app it is going to load the updated csv…