【发布时间】:2017-03-13 08:51:38
【问题描述】:
我已将 MS 项目文件提取为 CSV。它相当大(40 000 行),我正在尝试创建一个 Python 脚本,该脚本可以打印出任务/里程碑/依赖项之前的所有任务。
问题在于具有多个前置任务的任务。我已经存储了这些以“~”分隔的内容。
#Starting ID
MSid = 80329
#Subroutine FindPredesessors(MSid)
def FindPred(MSid):
#Get element[id] from the array
print(MSid)
#Predecessors of task
preds = arrMAX[MSid][1]
#List of split milestones
spID = spad.split('~')
#Attempt to loop through Function for each milestone in the split list
for h in range(len(spID)):
print(spID[h])
print(h)
FindPred(int(spID[h]))
FindPred(MSid)
我能做的最好的就是下面的输出
80329
['80326', '83171']
['80324', '80432']
['80323']
''
我可以得到最左边的路径,但我似乎无法返回并在拆分列表的其余部分循环该函数
【问题讨论】:
-
您肯定会多次遇到一些前任任务,因此请存储您已经搜索过的 ID,并在每次搜索之前检查这些 ID。
标签: python loops recursion tree ms-project