CSV Download in 1.19.0 retureing 'file' type, not csv

Summary

In the new 1.19 update downloading a csv file is not showing up as a .csv file but just as a “file”.

Steps to reproduce

Code snippet:


import pandas as pd
import streamlit as st



def convert_df(df):
    """
    converts df to csv
    :param df: df to make csv
    :return: df in csv
    """
    return df.to_csv(index=False)


def download_button(filename, data):
    st.download_button(
        label="Download Output File",
        data=data,
        file_name=filename,
        mime='text/csv',
        )
    

df = pd.DataFrame([1, 2, 3])

converted_df = convert_df(df)
download_button('testdf', converted_df)

I am expecting a csv file, not a “file”.

Debug info

  • Streamlit version: ‘1.19.0’
  • Python version: 3.10.6
  • Pandas version ‘1.4.3’

Prior to this version it was working fine.

image
image

What about:

download_button('testdf.csv', converted_df)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.