Announcements
Known issues updated. Learn more

Malformed file when uploading excel file with python sdk

Level 4

Hi there,

I get a malformed file when I try upload a simple excel file with python sdk

my code looks like:

xls = 'Path\\xxxxx.xlsx'		
	try:
		with open(xls, 'r') as upxls:
			dbx.files_upload(upxlsx.read(),'/test.xlsx', mode=dropbox.files.WriteMode("overwrite"))
     except Exception as e:
	    print e	

Is there a bug in my code or the dropbox python module?

1 Accepted solution

Accepted Solutions

Re: Malformed file when uploading excel file with python sdk

Dropboxer
You probably need to use open(xls, 'rb') instead of open(xls, 'r'). (Note the 'b' in the mode.) Try that out and let me know if it doesn't help.
Reply
Loading...
3 Replies

Re: Malformed file when uploading excel file with python sdk

Dropboxer
You probably need to use open(xls, 'rb') instead of open(xls, 'r'). (Note the 'b' in the mode.) Try that out and let me know if it doesn't help.
Reply
Loading...

Re: Malformed file when uploading excel file with python sdk

Level 2

Having the same issue, using the same code OP uses and I tried open(xls,'rb') but it's still coming out as corrupted. Any ideas how to sort it?

Reply
Loading...

Re: Malformed file when uploading excel file with python sdk

Dropboxer

@LiamGM Please open a new thread with more details on the issue you're seeing so we can take a look.

Reply
Loading...
API Support

Have a question? Our Dropbox Community is here to help you find an answer!
You won’t have to wait too long for a reply, but why not learn more about the Community while you’re here.

Not the right discussion for you? Find out what else our Community has to say about API Support.

Or, search our Help Center for even more.

Who's talking
Top contributors to this post