3

I have a script that scrapes some information, puts it in a dataframe and writes it to an excel file in dropbox. Now my program is running perfectly fine on my local computer but once I build a docker image of my project, the saved excel file comes out corrupted.

def write_excel_to_dropbox(dbx, df, excel_path):

    with io.BytesIO() as stream:

        with pd.ExcelWriter(stream) as writer:
            df.to_excel(writer, index=False)
            writer.save()

        stream.seek(0)

        dbx.files_upload(stream.getvalue(), excel_path, mode=dropbox.files.WriteMode.overwrite)

This is my function for writing and saving the excel file to my dropbox. It does actually save something but the file is corrupt. This is not the case when I run the script in pycharm. Does anybody know what's happening?

Thanks!

borisvanax
  • 670
  • 1
  • 6
  • 15

1 Answers1

3

I had to change the engine to 'xlsxwriter'

with pd.ExcelWriter(stream, engine='xlsxwriter') as writer: Happy this fixed my problem but still not sure why it did run on my local and not in docker.

borisvanax
  • 670
  • 1
  • 6
  • 15