Hi @abbmimn, thanks for your reply. I try with your code and it works perfectly in my local machine, but when I publish the app in Share Streamlit the file doesn’t download. I think theres is a little bug because when I add the atribbute “target=_blank” the file downloads, but with no name, and when I add the attribute “download=filename.csv” to define the download name, the file not download.
This is my code modified with your suggested code:
The function:
def get_table_download_link_csv(df): #csv = df.to_csv(index=False) csv = df.to_csv().encode() #b64 = base64.b64encode(csv.encode()).decode() b64 = base64.b64encode(csv).decode() href = f'<a href="data:file/csv;base64,{b64}" download="captura.csv" target="_blank">Download csv file</a>' return href
The call of the function:
st.markdown(get_table_download_link_csv(df), unsafe_allow_html=True)
Thanks again