replace by column name

Hello.

I have a binary table with many columns. All the 1's which are strings need to be replaced by the corresponding column name, so that this transformed table can be used to mine frequent itemsets 

Hi,

To do this convert all columns to String first with "Number to String".

Then connect to this the "Extract Column Header" node, and connect the top out port from this to "Transpose" node followed by "TableRow To Variable LoopStart" node.

Now connect a "Column Filter" node up to the outport of "Number to String". Turn on variable ports (right click and choose Show Variable Ports) on the "column filter" node. Connect the variable outport from "TableRow To Variable LoopStart" node to the in variable port of the "Column Filter" node. This bit is a bit finnicky, in the column filter add just one column to the include list, and select Enforce Inclusion, go to the flow variables tab, and in the 0 row, from the dropdown select the variable "Column Header". Now click okay.

Now attach a "String Replacer" node, and in the wildcard pattern put in "1", now go to the flow variables tab, and select the variable "Column Header" from the dropdowns next to both "ColName" and "Replacement". Now connect a "Loop End (Column Append)" node and thats it.

Hope this helps,

Simon.

Hi Simon,

 

Can you take a look at the attached workflow. I am essentially trying to find frequent itemsets in fingerprints so as to search for them in the test set.

 

The column filter node and "String replacer" after that give problems. The string replacer cannot find a string from column filter. I even tried to remove other columns before the extract column names node to prevent problems.

 

thanks in advance.

Ahaha, you was soo close with that !!

Just replace the Loop End node for a Loop End (Column Append) node.

 

That will do it

Simon.

Oh, and it does take a while to complete, as there are 1000 columns in there for it to go through, so do be patient!

Brilliant Simon! Just Brilliant!