Jump to content

TOP/PDG Python processor fetch files


mik74

Recommended Posts

Hello,

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

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...