Opening spreadsheet returns InMemoryUploadedFile

Posted by David542 on Stack Overflow See other posts from Stack Overflow or by David542
Published on 2012-10-14T21:45:59Z Indexed on 2013/11/05 3:55 UTC
Read the original article Hit count: 1344

Filed under:
|

I have a user uploading a file to a website and I need to parse the spreadsheet. Here is my code:

input_file = request.FILES.get('file-upload')
wb = xlrd.open_workbook(input_file)

The error I keep getting is:

TypeError at /upload_spreadsheet/
coercing to Unicode: need string or buffer, InMemoryUploadedFile found

Why is this happening and what do I need to do to fix it? Thank you.

For reference, this is how I open the file in the shell

>>> import xlrd
>>> xlrd.open_workbook('/Users/me/dave_example.xls')
<xlrd.Book object at 0x10d9f7390>

© Stack Overflow or respective owner

Related posts about python

Related posts about django