You can read the entire file into memory using:
data = urllib2.urlopen(url).read()
Once the file is in memory, you can load it into xlrd
using the file_contents
argument of open_workbook
:
wb = xlrd.open_workbook(url, file_contents=data)
Pass the url in as the filename as the documentation states it might be used in messages; otherwise, it will be ignored.
Thus, your traverseWorbook
method can be rewritten as:
def traverseWorkbook(url):
values = []
data = urllib2.urlopen(url).read()
wb = xlrd.open_workbook(filename, file_contents=data)
for s in wb.sheets():
for row in range(s.nrows):
if row > 10:
rowData = processRow(s, row, type)
if rowData:
values.append(rowData)
return values