Skip to main content
Question

Malformed file when downloading xlsx file with python sdk

  • May 23, 2025
  • 1 reply
  • 20 views

Forum|alt.badge.img

I am accessing box to download an xlsx file, the file gets downloaded, yet it is corrupted, may you help ? thanks in advance

1 reply

Forum|alt.badge.img

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.