Save dataframe to CSV (UTF-8)

Hello,

To begin with, I want to say that have just started using streamlit, and really like it

I am working on an app that should have the function of loading an excel file into a data frame, then corrections are made such as. delete some columns and change names etc, and after that you should be able to export a new csv file.

The problem I have right now is that I have not yet managed to find a solution on how to export the new data from the data frame.

This Base64 works,
but the problem is that it is not printed as UTF-8 and therefore ÅÄÖ is Γƒ Β₯ À â

Therefore need help with alternatives on how I can save with data frame to csv

Thanks!

1 Like

Hi @Dackefejd, welcome to the Streamlit community!

I suspect the fix might be as simple as specifying the encoding in the encode statement:

object_to_download.encode("UTF-8")

Best,
Randy

Hi @randyzwitch, Thanks for reply!

I have tried this solution before, but the problem persists.

But then I discovered that it seems to be excel that is the problem. Do I open the csv in e.g. Notepad ++ works as it should.

Thank you for your answer and solution!

1 Like