Hi, I’m trying to export and download a dataframe to a .csv file with the function:
> def get_table_download_link_csv(df):
> csv = df.to_csv(index=False)
> b64 = base64.b64encode(csv.encode()).decode()
> href = f'<a href="data:file/csv;base64,{b64}" download="download.csv">Download csv file</a>'
> return href
The function works great in my local machine, but when I publish the app in Streamlit Share, the function doesn’t work properly and when I click in the link nothing happends. I noticed that when I right click on the link and select “save link as” the file is downloaded with the defined name.
I tried to add the “target=”_blank" attribute, and it works correctly only if the file name is not specified, but I think that this is not the most usable for the user, since the file is downloaded without a specific extension.
Thanks for the support