ROW CONCATENATION - every 4th one...

Hello - it seems that something was changed in JAVA snippet, I will explain below, having table like this one:
COLUMN0
AB

XA

DD

RET

AC

CT

RF

RET

And using java or any other means I want to have table:
COLUMN0

AB$XA$DD

AC$CT$RF

Problem is that I remember I was using JAVA Node to complete similar tasks - using code below:

out_EL_DATA+=c_Row0;
out_EL_DATA+="$";
if(c_Row0.equals("RET")){
    out_EL_DATA="";
}

So after going through whole table it should look like this:

COLUMN0     COLUMN1
AB                   AB$

XA                   AB$XA$

DD                  AB$XA$DD$

RET               

AC                  AC$

CT                  AC$CT$

RF                  AC$CT$RF$

RET

The problem is I have null in front of every string in COLUMN1 and then string from row of COLUMN0 with $ at the end. Its like every time out_EL_DATA is being nullyfied (I remember it was not a case previously). Is there another way to do this or why it does not work anymore?

Thanks!

Hi,

you can also use the Column to Grid node. And afterwards a column combiner or a string manipulation node to make one column out of the four (IF it is always four as in your example.)

Best, Iris

If you have variable occurences of "RET" in your table, you could:

  • use the Rule Engine to create a new column containing 1 in every row with a "RET"
  • calculate the cumulative sum (e.g. using an R node with the function cumsum)
  • group by the cumulative values using the GroupBy node with an aggregation method to concatenate your strings.

Best

Jan

 

Thanks for suggestions guys, will try it out.