Снимок экрана проблемы Итак, у меня есть скрипт ниже, который читает файл CSV, а затем добавляет данные, основанные на атрибутах рекламы и файле CSV, в файл Excel. Когда я пишу, чтобы превзойти, дата не go выглядит как гггг-мм-дд, а как 'гггг-мм-дд
corp_WH_unique_file = pd.read_csv(CorpFilteredFILE_Unique, usecols=['Employee_ID', 'location', 'Effective_Date'])
# get length of corp_wh_unique file
corp_WH_unique_file_rowCount = len(corp_WH_unique_file)
corp_WHTerm_WB = openpyxl.load_workbook(TermFIle)
corp_WHTerm_WS = corp_WHTerm_WB.get_sheet_by_name("Corp-WH")
for corp_WH_Values in range(corp_WH_unique_file_rowCount):
empID_corp_WH = str(corp_WH_unique_file.iloc[corp_WH_Values]['Employee_ID'])
empID_corp_WH = empID_corp_WH.replace('.0', '')
termdate_corp_WH = str(corp_WH_unique_file.iloc[corp_WH_Values]['Effective_Date'])
office_corp_WH = corp_WH_unique_file.iloc[corp_WH_Values]['location']
term_rcvd_corp_WH = today_date
term_cleanup_corp_WH = dt.datetime.strptime(term_rcvd_corp_WH, '%Y-%m-%d') + timedelta(days=30)
term_cleanup_corp_WH = str(term_cleanup_corp_WH.strftime('%Y-%m-%d'))
conn.search('dc=PVHCORP,dc=COM', '(msExchExtensionAttribute21=0' + empID_corp_WH + ')',
attributes=['givenName', 'sn', 'SamAccountName', 'physicalDeliveryOfficeName'])
# try the below if you dont get error
try:
userinfo = conn.entries[0]
firstName_corp_WH = str(userinfo.givenName)
lastName_corp_WH = str(userinfo.sn)
Pusername_corp_WH = str(userinfo.SamAccountName)
corp_nextRow = corp_WHTerm_WS.max_row + 1
print(term_cleanup_corp_WH)
corp_WHTerm_WS.cell(row=corp_nextRow, column=2).value = termdate_corp_WH
corp_WHTerm_WS.cell(row=corp_nextRow, column=3).value = term_rcvd_corp_WH
corp_WHTerm_WS.cell(row=corp_nextRow, column=4).value = term_cleanup_corp_WH
corp_WHTerm_WS.cell(row=corp_nextRow, column=5).value = firstName_corp_WH
corp_WHTerm_WS.cell(row=corp_nextRow, column=6).value = lastName_corp_WH
corp_WHTerm_WS.cell(row=corp_nextRow, column=7).value = Pusername_corp_WH
corp_WHTerm_WS.cell(row=corp_nextRow, column=9).value = empID_corp_WH
corp_WHTerm_WS.cell(row=corp_nextRow, column=10).value = office_corp_WH
corp_WHTerm_WB.save(str(TermFIle))
# if error is received print user not found and pass
except IndexError:
print('Corp - WH Employee id: ' + empID_corp_WH + ' not found in AD.')
pass