Dear KNIME communauty,
I am currently trying to work on multiple files using a List File node in a loop to work on each file individually.
All files have the same type and number of columns, but can differ by their column names.
For instance, file 1 has columns 'structure' and 'name' wile file 2 has columns 'STRUCTURE' and 'id'.
My problem is that I have to configure manually the following nodes between each iteration because of the change of column name, so I thought using column indices instead would be a good idea...
Does anyone know if there is a simple way to identify a column by its index rather by its name, for instance Col(1), like the variable ROWINDEX?
Here is a simplified idea of the workflow I am currently trying to build:
List File -> Tablerow to loop -> SDF Reader -> String Manipulation on second column -> Loop End
Thank you for your help! :)
PS: I am using knime.2.9.2 on Centos 6.5 x64
The Java snippet can do this I believe. If you are using the string manipulator node can you do this in Java and use the snippet?
If you give an example of the action you want to do with a couple of mock tables I can see if I can come up with an example snippet for you.
Well, you could transpose the table, generate new row ids with rowid node, then transpose back. That will give you consistent column names.
Probably the Insert Column Header can solve your problem without accessing the columns by their index. That way you can create a consistent table header for each intermediate column in the loop.
Good point Aborg, that reminds me, in fact the "extract column header " node will generate some default column index for you, that should deliver exactly as needed.
Thank you all for your suggestions!
In the end, I simply used a Python Snippet, since I am not very confortable in java... (the corresponding workflow part is attached).
I also tried to use the Insert Column Header node, but I couldn't make it work, since there were actually some files that had more columns than others and it seems each column has to be defined in the second input table.