Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Labels (2)
1 Reply
Anonymous
Not applicable
Author

Thanks, it's very interesting 0683p000009MACn.png
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.