Reformating multiple data columns

I have a file with dozens of strings that I want to recast as dates.  Luckily they are all of the exact same format.  I can use the STRING TO DATE/TIME node just fine but its a lot of work to repeat the node many times over and makes the workflow ugly.  So I decided to try it as a loop.

I created a file with a list of all the columns I needed to convert (one column per line) and read that file in.  Then I passed the file to a TABLE ROW TO VARIABLE LOOP START node.  The variable of columnname is passed to to the STRING TO DATE/TIME node. 

This works great on the first iteration of the loop.  It fails on the second because it says the file types do not match.  In the second iteration of the loop I can see the first datae column is put back to to a string again.

Im not sure what I want to do is possible.  Could someone confirm you can do this?  Perhaps a link to a sample doing something similar will help me see my mistake. Thank you.

Hi,

you can also try the Column Auto Type Cast node (https://www.knime.org/files/node-documentation/org.knime.base.node.preproc.coltypechanger.ColumnTypeChangerNodeFactory.html)

If all your strings (dates) have the same date format they will be converted into dates.

If this doesn't work, I would need to see the workflow to know what is the problem... In principil, this is doable, yes.

Cheers, Iris

have a look, this works to your specification

there are a few points:

- the loop end can be set to allow variable column types and also changing table specifications, which you may wnat to do in future

- however this loop end concatenates the data from each iteration into additional rows, which is not what you want

- to do what you want, you need to filter out each column you are taretting, and use a loop end (column append) node

- the workflow attached does this, using a column list loop start to cycle through the columns. To make it work to your specification of you a separate input table of columns, I turned that into a reference table against which the current table column is tested to see if it is one of the specified columns. If it is, it will then do the conversion before passing to the loop end, otherwise it pass direclty to the loop end

David

Thank you for the sample.  As I develop my skills in KNIME development I think its especialy important to have a solid understanding of looping capability to be successful.