I have a download function for users to download zip files of pandas df that has been converted to csv. But unfortunately it also save it to my local folder. Is there anyway to prevent this?
def downloader(list_df, datafile, file_type):
file = datafile.name.split(".")[0]
#create zip file
with zipfile.ZipFile("{}.zip".format(file), 'w', zipfile.ZIP_DEFLATED) as file_zip:
for i in range(len(list_df)):
file_zip.writestr(file+"_group_{}".format(i)+".csv", pd.DataFrame(list_df[i]).to_csv())
file_zip.close()
#pass it to front end for download
zip_name = "{}.zip".format(file)
with open(zip_name, "rb") as f:
bytes=f.read()
b64 = base64.b64encode(bytes).decode()
href = f'<a href=\"data:file/zip;base64,{b64}\" download="{zip_name}">Click Here To Download</a>'
st.markdown(href, unsafe_allow_html=True)