Combine two cells

HI team,
I have a input and output here please help me how to write a flow chart

Input
|Code| value| Code| value| Code| value|

|RATED| 600 LB| STROKE | 8 IN| SPEED| 60 IN/MIN

Output

RATED: 600 LB, STROKE: 8 IN, SPEED: 60 IN/MIN

Hello @Ranjit,

so you start with 4 columns and want to finish with one column or?

Br,
Ivan

1 Like

yes ipazin, I have 6 columns and need to combine all and put them in a single cell like the output shown above

Hello @Ranjit,

you can use join() function from String Manipulation node.

join(code1, ": ", value1, ", ", code2, ": ", value2, ", ",...)

Br,
Ivan

6 Likes

thq ipazin i got the output

1 Like

Hi I have one more doubt in the above inputs
There are four columns ex sl.no,column 1,column2,column3,column4 and having data in three rows like row 1 having data in all columns but In row 2 having data in column1 and column2 only in this case by using above mentioned formula I am not getting extact output could you please help me how to do

Hello @Ranjit,

I see. You will get missing value whenever there is a missing value in any of the joining columns. To deal with missing values prior to joining you can use Missing Value node. Either replace it with empty string "" or any other value you want. However this will still lead to weird output you probably don’t want so here is another way. Use Column Aggregator node on all columns you want to have in single cell with Concatenate aggregation method, comma as separator and exclude missing values from concatenation. Then apply folowing regex in String Manipulation node to replace every second comma (starting from first) with colon.
regexReplace( $YourColumnName$, "([^,]+),([^,]+,?)" ,"$1:$2")

Give it a try and if any issues of questions feel free to ask.

Br,
Ivan

3 Likes

hi,
I have tried multiple times but couldn’t get proper output

Hello @Ranjit,

here is workflow example with above approach:
2021_12_06_Combine_Multiple_Cells.knwf (19.2 KB)

Check it out and if any questions feel free to ask.

Br,
Ivan

hi,
How you written regex expression, i want to know. Can you please guide me or any material related to this

Hello @Ranjit,

take a look here for more:

And for testing regex I use this page:

Br,
Ivan