python newbie here! :)
basically, trying scan excel file's column (which contains dates) , if date in cell 7 days in future...do something. since learning, looking @ 1 cell before progress , start looping through data.
here current code isn't working.
import openpyxl, smtplib, datetime, xlrd openpyxl import load_workbook datetime import datetime wb = load_workbook(filename = 'franklin.xlsx') sheet = wb.get_sheet_by_name('master') msg = 'subject: %s\n%s' % ("shift reminder", "dear rem ") cell = sheet['j7'].value if xlrd.xldate_as_tuple(cell.datemode) == datetime.today.date() + 7: print('ok!')
here error code getting: 'datetime.datetime' object has no attribute 'datemode'
i've tried searching high , low, can't quite find solution.
your cell
variable seems datetime.datetime
object. can compare this:
from datetime import timedelta if cell.date() == (datetime.now().date() + timedelta(days=7)): print("ok")
Comments
Post a Comment