ok I am getting the attribute Error:enter with statement. trying to have python check for next Mondays date and if there is that date move forward then if there is change it to Tuesday then if there is not print out error: there is no starting next week... but getting that error though and cant figure it out.
import os
import pandas as pd
import datetime as DT
from dateutil.relativedelta import relativedelta, MO, TU
hr_file = "Upcoming Hires.xlsx"
with pd.read_excel(hr_file, sheet_name="New Hires",parse_dates=["Start Date"]) as reader:
now = now = DT.datetime.now()
nm = now - relativedelta(weekday=MO(+1))
next_monday = now - relativedelta(weekday=MO(+1))
if next_monday in reader:
print("true")
if not next_monday in reader:
nm = now - relativedelta(weekday=TU(+2))
next_monday = nm.strftime("%#m/%#d/%#y")
if next_monday in reader:
print("had to move the date for the start date to tuesday but it True")
if not next_monday in reader:
print("error: there is no starter next week...")
getting this for the error
AttributeError Traceback (most recent call last)
c:\masterscript\test.py in <cell line: 1>()
----> 7 with pd.read_excel(hr_file, sheet_name="New Hires",parse_dates=["Start Date"]) as reader:
8 now = now = DT.datetime.now()
9 nm = now - relativedelta(weekday=MO(+1))
AttributeError: __enter__