I want to convert some data of dates into the string after checking them in a specific range. I have first converted all data into type float so that it can provide output as dates format but when I applied this for the dates it shows:
a1 = float(a1)
ValueError: could not convert string to float: '0000-00-00'
My whole code is:
import xlrd
import os.path
from datetime import datetime
date_array = []
wb = xlrd.open_workbook(os.path.join('E:\Files','SummaryLease.xlsx'))
sh = wb.sheet_by_index(0)
for i in range(1,sh.nrows):
a1 = sh.cell_value(rowx=i, colx=80)
if a1 is '0000-00-00':
date_array.append('flag')
else:
a1 = float(a1)
a1_as_datetime = datetime(*xlrd.xldate_as_tuple(a1, wb.datemode))
date_array.append(a1_as_datetime.date())
print(date_array)
How should I solve this?