Help for dynamically change the file name for readers and writers

Hi: I’m trying Knime and it’s awesome. However, I don’t understand the
API completely yet. I created a project using the GUI.

Then I launched my Eclipse Ganymede IDE and created a Java Project which can
run the workflow I previously created with the GUI, using the
WorkflowManager class. It’s great and it works but in the workflow I
read an ARFF file and the path to the file is contained in the flow.
If I pass my program to another person it won’t work unless he put the
data in the same way in his file system.

Is it any possibility to dynamically change the data location that the
workflow knows and use a relative path in my java project, for example
"src\resources\testdata.arff" or similar???

My final goal is use Knime GUI for design some experiments or datamining processes and make
software on top of that. Therefore I need to be able to easily change
the data I will pass to the predictor for classify it.

Thanks in advance

I guess the best way of doing this is to define a workflow variable on the workflow project (search for "expert mode" on the FAQ page) and then use that variable in the file reader to set the URL. Unfortunately the documentation on the variable concept isn't as good as it could be (it's still beta and disabled by default), though you find some nice pointers in this forum, e.g. this post here. Once the variable is defined (and used), you can programmatically change it on the WorkflowManager using the addWorkflowVariables method. Please note that KNIME core code wasn't originally meant to be public API, so you might find it a bit hard to use. Once you start developing your own nodes (using the extension wizard), things should be much better documented.

One more thing that came to my mind while reading your post (and your EMail). If you are wrapping a KNIME instance in your java code, be aware that KNIME needs to run in an OSGi context to function properly. It is not sufficient to control the WorkflowManager from a plain Java project: It will resolve dependencies in the KNIME core properly but it will have problems loading nodes and types which are defined in 3rd party bundles, such as the chemistry extension, the math formular node, the labs projects, etc…

Actually, I’m using Maven in my Java project. I manually installed a couple of KNIME jars in my maven repo, and added dependencies to my project referencing those jars. It seems being enough for now, however, I will check the OSGi stuff… I’m realy not aware about that and as far as I know OSGi is the whole background in plugin development.

Thanks

I have a need that I thought may be somewhat similar though for a much simpler cause. I used List Files node to index the files in a pre-defined directory (on Windows server). Now I want to pass the entries (e.g., file URLs), one by one, to File Reader node so I can parse the files. How do I do that passing?

The "e.g. this post here"  link in the first post ("Thu, 05/06/2010 - 03:55 — wiswedel") doesn't work. :-(

Barry

Dear Barry:

We corrected the link.

For your specific use case you can also use a pre-configured meta node called "Iterate list of files". Connect the output of your "List Files" node to the input of the meta node, go into the meta node (double-click), then execute the "TableRow to Variable Loop Start" in order to propagate the variables and configure the "Variable base File Reader" as usual.

Hope this helps.