Jump to content
Sign in to follow this  

TOP/PDG Python processor fetch files

Recommended Posts


I would like to fetch files using python into work items.

I have an array of file paths and I want to create a work item per file basically to process them.
Same way as the “filepattern” top but with python processor.

I can not find the python way to do that.

Thank you guys

Share this post

Link to post
Share on other sites

Hi Mikel,

I believe this question should be posted in the Scripting Forum

But here's how I would do it

Inside a Python Processor,

from os import listdir

path = r"C:\someFolder"
allFiles = listdir(path)

for file in allFiles:
	newItem = item_holder.addWorkItem()
	newItem.setStringAttrib("file", file)
	newItem.setStringAttrib("path", path + "\\" + file)

Basically, using this documentation page, you can see how to add a work item
This tells you that the resulting object is → pdg.WorkItem
If you follow it to its documentation page, there you can see how to add an attribute to said work item

Edited by Alain2131

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this