As the title indicates, is it possible to itterate over the rows of a tables with the Java Sniplet?
The java nodes performs it’s operation once per row. As I mentioned over here http://www.knime.org/node/555 it may be possible in one or more of the Jython nodes.
From the node description file accesible via the GUI: “Executes a JPython script, taking 1 input DataTable and returning 1 output DataTable. A simple example script is included (but commented out) in the dialog’s text window of the Script tab.”
Check that out.
Perhaps someone at Knime has a comment?
Thanks. I’ll have a look at this, but I am don’t know Python, so this might be a limiting step.
Jay wants to have someone at KNIME to comment on it. There is unfortunately not much to comment. The java snippet node is limited to one row at a time (without the possibility to secretly interchange information between different row invocations). The jython nodes allow the full flexibility of iterating the table multiple times, global data structures and so forth, though is harder to use (especially for python newbies).
Being the author of the java snippet node, I’d love to enhance it or add a new one with arbitrary iterators and output (similar to the python node). If someone wants to sponsor the development, he is more than welcome. This would allow us to accommodate resources and help to add such functionality as part of the usual “business” (and not in my spare time).
Does that Jython node simple allow one to take mutliple passes through the data without having to hold everything in memory? I’d asked to see if someone would comment as I wasn’t fully sure of the reason for the question and I have never touched the Jython nodes…anyways thanks for the comments.
Yes, the Jython nodes can take multiple passes on the input data without keeping the data in main memory. They expose some of the functions we have in KNIME core to the end user. One of these methods is the
iterator() method, which will use a native KNIME iterator. Depending on whether the framework keeps the input data in memory or on disk you will get a different iterator instance (you won’t notice the difference, though). Along similar lines there is a post about the functions available in the jython nodes. You may find that useful to get an idea on what functions are available.