PYthon Scripts

Hello,

I am relatively new to knime and I have some trouble setting up a workflow using existing python scripts.

I mainly have two questions:

1. I tried to use the external tool node, and specified my script there. This worked fine, but one is restricted to 1 input file and 1 output file. In my example I need 2 Input Files as well as 2 output files. Do you have any suggestions if (and how) one could use external tool nodes for this purpose?

2. Since I didn't found a proper way to use external tool nodes with multiple In/Out-Files, I started looking for direct pyhon integration and found Python Scripting in Community Nodes as well as Jpython in KNIME Labs.  Can anyone comment on which one to use? Quickly: In my script, I do some modification on the first input file, and afterwards compare it to the second input file, as output a txt file consisting some information as well as the modified file is provided.

And if one of the to options (Python Scripting vs. Jpython) is better suited, do you happen to have some tutorial material or example how to set up such a node?

Spec for my desired node:

Input Port: 0,1 (two files)

<NODE>: use these two files, do some fancy calculations and output the results in two files

Outout Port: 0,1 (use the python created output to do something else in knime)

 

Thanks a lot

Andrea

 

 

Hi Andrea, 

I would suggest using an input and output files that contain paths to the multiple input and output files.  

In the example of two input files, just create the files normally using a csv reader, but then collect those file paths into a KNIME table and send this to the external tool node.  Likewise, when you write the results from your script, write out your results files, but then also write out an index file containing paths to your reults file.  You can then collect the index file in the external tool node and read the results files once you know where they live.  

 

Or, you could try adapting the approach described here - http://www.knime.com/files/006_kuduk_roughley_vernalis.pdf - see slides 16-19.

If you need to know how the snippet code is generated dynamically, then please message me and I will dig out the details

Steve

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.