python - Convert BytesIO into File - Stack Overflow

PHOTO EMBED

Tue Mar 01 2022 03:44:37 GMT+0000 (Coordinated Universal Time)

Saved by [deleted user] #python

macro_template_path = r'C:\Users\baphuoc.phamhoang\Box\developement\Streamlit_Dashboards\dashboards\Dashboard.xlsx'
with open(macro_template_path, 'rb') as f:
        buffer = BytesIO(f.read())
with pd.ExcelWriter(buffer, engine="openpyxl", mode="a", if_sheet_exists="replace") as writer:
        macro_res_2days_df.to_excel(writer, 'input_data', index=False)
temporarylocation=r"C:\Users\baphuoc.phamhoang\Box\developement\Streamlit_Dashboards\dashboards\ran_capactiy_dashboard\macro_db_testout.xlsx"
with open(temporarylocation, 'wb') as out:
        out.write(buffer.getvalue())
buffer.close()
content_copyCOPY

https://stackoverflow.com/questions/29324037/convert-bytesio-into-file