Added xls detection.

This commit is contained in:
Greg Thornton
2011-07-14 13:47:07 -05:00
parent c19e2f2c5b
commit f6d7888d9e
+8
View File
@@ -112,3 +112,11 @@ def dset_sheet(dataset, ws):
ws.write(i, j, col)
def detect(stream):
"""Returns True if given stream is valid XLS."""
try:
xlrd.open_workbook(file_contents=stream)
return True
except xlrd.XLRDError:
return False