Python: xlrd discerning dates from floats
I wanted to import a file containing text, numbers and dates using xlrd on Python. I tried something like: if "/" in worksheet.cell_value: do_this else: do_that But that was of no use as I latter discovered dates are stored as floats, not strings. To convert them to datetime type I did: try: get_row = str(datetime.datetime(*xlrd.xldate_as_tuple(worksheet.cell_value(i, col - 1), workbook.datemode))) except: get_row = unicode(worksheet.cell_value(i, col - 1)) I have an exception in place for when the cell contains text. Now i want to get the numbers as numbers and the dates as dates, because