Welcome to the new Box Support website. Check out all the details here on what’s changed.

Malformed file when downloading xlsx file with python sdk

New post

Comments

1 comment

  • Rui Barbosa

    Hi Massimo,

    Python open does not close the file automatically, and I suspect it is why your file is getting corrupted.

    Try it like this:

    file_id = '1234'
    
    download_file = client.file(file_id).get()
    with open("/home/wsuser/work/" + download_file.name, 'wb') as transfer_file:
    download_file.download_to(transfer_file)

    The "with"statement will close the file once the download is done.

    0
    Comment actions Permalink

Please sign in to leave a comment.