converting ordinal to binary

I'm trying to convert about 50 survey questions with values sometimes 1-4, sometimes 1-5, sometimes 1-6 to individual columns representing the value of the response. The data is read in as Int, but I can convert it to String so that the One2Many node could be used.  For now I actually only need the "1", but I can imagine using all five or six values at some point. In other tools I have taken Q2 (question 2) and converted it to Q2_1, Q2_2, Q2_3, etc.

The problem I have is that the One2Many node creates the column name as the value of the text. Since each of my questions have the same values, I cannot used One2Many on multiple nodes.

I could use a Math node (and this is what I'm doing now), but I have to create 50+ nodes for each response value (_1, _2, etc.).

It appears to me that the Java Snippet node could work, but frankly, since I have to populated the output fields manually, one at a time, this is quite slow (the Math node is faster to build--I just copy and paste the nodes, and only have to change a single number -- I actually create 10 math nodes at a time and copy / paste those).

I've tried looping but without success.

Thanks for any help!


Hi Dean, what was the problem with looping? (Were the column names generated in conflict when the Column List Loop Start and Loop End (Column Append) nodes used?)

Cheers, gabor

Looping is the way forward. Below should point you in the right direction,

use column list loop start.

then use extract column header node to get column name in a row. Convert this to a variable with table row to variable. Then take data from the other outport from column header node and generate a column with this variable using rule engine node and setting default label to this variable. Now use column combiner node on current column and newly generated column from rule engine node. Finally a colmn filter node choosing the combined column only to remain followed by a rename node, in which its renamed by the variable set earlier.

complete the loop with a loop end column append. Hope it helps.