我使用的是Modeler18.0,而且我是这个工具的新手。
我继承了30个流文件。每个流以30个excel源节点开始,文件名类似于.xlsx (例如c:\source\regl_sales_01_WI_2017Q3.xlsx)。我需要为源文件的2017Q4版本更新所有900个节点。
我是否可以使用某种类型的脚本来执行此操作,以便查找和替换?这会是一个独立的脚本吗?如果我只能识别脚本和节点,我似乎可以使用node.setPropertyValue("full_filename","c:\source\regl_sales_01_WI_2017Q3.xlsx")之类的东西。
谢谢
发布于 2018-04-12 23:02:46
我认为您的问题可以通过使用独立脚本和stream.findAll()-functionality来解决。
你可以这样做:
from os import listdir
from os.path import isfile, join
session = modeler.script.session()
tasks = session.getTaskRunner()
mypath = 'C:\\yourpath'
streams = [f for f in listdir(mypath) if (isfile(join(mypath, f)) and f.endswith(".str"))]
for streamFile in streams:
print(stream.getName()+" is getting processed.")
stream = tasks.openStreamFromFile(demosDir + streamFile, True)
inputNodes = stream.findAll("excelimport", None)
for in in inputNodes:
ff = in.getPropertyValue("full_filename")
ff.replace("2017Q3.xlsx", "2017Q4.xlsx")
in.setPropertyValue("full_filename", ff)
print(stream.getName()+" is processed.")
stream.close()我没有测试它,但是它应该不需要太多的调整就能工作。
https://stackoverflow.com/questions/48895543
复制相似问题