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
fileobject (which, IMO, would be ideal), only taking in afilenameitself or the abovefile_contentsmethod.If
file_contentsdidn’t exist or didn’t work, you’d have to usetempfileto write the response to a temporary file and read that.