How to convert rows to group rows

One Star

How to convert rows to group rows

Hi,
I want to group some rows with a delimiter (|) and limiter (3) :
IN
value1
value2
value3
value4
value5
value6
value7
value8
value9

to
OUT
value1|value2|value3
value4|value5|value6
value7|value8|value9
I think it's possible with a routine and a String buffer but have you another solution ?
Thanks
One Star

Re: How to convert rows to group rows

Thanks, it's very interesting Smiley Happy
I think I have another solution with a routine but it's not better...
This is my routine
public class StringPivot {
static int nb_lines = 0;
static String delimiter = "";
static String buffer = "";
public static void addBuffer(int limiter, String delimiter, String value) {
nb_lines += 1;
if ((nb_lines % limiter) == 0) {
buffer += value + "\n";
}
else {
buffer += value + delimiter;
}
}

public static String getBuffer() {
return buffer;
}
}

In a tJavaRow2 :
StringPivot.addBuffer(3, "|", row2.value);

After this, I put the result in a temporary CSV file (I don't use it after, it's validate my tJavaRow2)
At the end of job I keep my String Buffer :
StringPivot.getBuffer();

in a tFixedFlowInput
I put this code :
StringPivot.getBuffer()

After I can use a tFileOutputDelimited to save my transformation.