I am getting an Excel file using urllib2 and saving into response below. I want to be able to process this excel file using xlrd or similar. I included some info below, let me know if I can provide more info. How can I have response object transformed into an object I can play with?
response = <addinfourl at 199999998 whose fp = <socket._fileobject object at 0x100001010>>
response.read() prints: '\xd0\xcf\x11\xe0...'
Headers:
Content-Type: application/vnd.ms-excel
Transfer-Encoding: chunked
Using
xlrd
, and based on its API documentation, it appears like you can use something similar to this:It doesn't appear to support reading a
file
object (which, IMO, would be ideal), only taking in afilename
itself or the abovefile_contents
method.If
file_contents
didn't exist or didn't work, you'd have to usetempfile
to write the response to a temporary file and read that.