我正在为某些任务预处理带有开始日期(代码中的“sd”)和结束日期(代码中的“ed”)的原始 excel 文件,并且我为新列表/列编写了一个 if 代码,它显示了每个任务的状态任务。即未开始,正在进行和完成。显而易见的条件是如果 sd 为空则任务未启动,如果 sd 存在但 ed 为空则任务继续进行,如果 sd 和 ed 都存在则任务完成。但只是完成作品的条件。我在 python 3.8 中使用 spyder
#INVOICE PRE-PROCESSING REV 00
import pandas as pd
#Reading excel file
df1 = pd.read_excel("Invoices Detail.xls")
#Reading Columns from excel
wf,tk,sd,ed,dd,st,vn,jn,iv,an,lk = df1['Workflow ID'].tolist(),df1['Task'].tolist(),df1['Start_Date'].tolist(),df1['End_Date'].tolist(),df1['Delay(Days)'].tolist(),df1['Status'].tolist(),df1['Vendor Name'].tolist(),df1['JOB Number'].tolist(),df1['INV_AMT'].tolist(),df1['Assignee/Completed by'].tolist(),df1['Alfresco Link'].tolist()
#New Columns for output file
a = len(tk)
stage,tk_name,status = [None]*a,[None]*a,[None]*a
#Start and End Dates for each task
t1_sdate,t1_edate,t2_sdate,t2_edate,t3_sdate,t3_edate,t4_sdate,t4_edate,t5_sdate,t5_edate,t6_sdate,t6_edate,\
t7_sdate,t7_edate,t8_sdate,t8_edate,t9_sdate,t9_edate,t10_sdate,t10_edate,t11_sdate,t11_edate,t12_sdate,t12_edate = \
[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,\
[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a,[None]*a
for i in range(0,a):
if tk[i] == "Upload Invoice and Initiate Workflow(Document Controller)":
stage[i] = "S1: Uploading & Initiation"
tk_name[i] = "T1: Upload Invoice and Initiate Workflow(Document Controller)"
t1_sdate[i] = sd[i]
t1_edate[i] = ed[i]
if t1_sdate[i] == pd.NaT:
status[i] = "Not Started"
elif t1_sdate[i] != pd.NaT and t1_edate[i] == pd.NaT:
status[i] = "On Going"
elif t1_sdate[i] != pd.NaT and t1_edate[i] != pd.NaT:
status[i] = "Completed"
elif tk[i] == "Document Controller Attach DO and Fillout the Related Details (ACL)":
stage[i] = "S2: Filling Details & Attaching DO"
tk_name[i] = "T2: Document Controller Attach DO and Fillout the Related Details"
t2_sdate[i] = sd[i]
t2_edate[i] = ed[i]
if t2_sdate[i] == pd.NaT:
status[i] = "Not Started"
elif t2_sdate[i] != pd.NaT and t2_edate[i] == pd.NaT:
status[i] = "On Going"
elif t2_sdate[i] != pd.NaT and t2_edate[i] != pd.NaT:
status[i] = "Completed"