append cell entries

hi all,

is it possible to concat array-entries of one column row-wise (using java snippet node)?

eg. my column is:

[0,1,2,3,4,5]

[6,7,8]

[9,10,11,12]

and my output column should be:

[0,1,2,3,4,5,6,7,8,9,10,11,12]

[0,1,2,3,4,5,6,7,8,9,10,11,12]

[0,1,2,3,4,5,6,7,8,9,10,11,12]

thank you!

...or the output could also be:

[0,6,9,1,7,10,2,8,11,3,12,4,5]

[0,6,9,1,7,10,2,8,11,3,12,4,5]

[0,6,9,1,7,10,2,8,11,3,12,4,5]

thanks.

Should be possible with the GroupBy node on this column and use "Concatenate" or "List" I believe as the Aggregation method.

Simon.

hi Simon,

thanks for the hint. the GroupBy-node works but it still depends from the chosen columns. (If you only choose one column it works well. if you choose all columns there will be no concatenate-effect...furthermore it returns only one row by operating on only one cell, but doesn´t append the result to the whole input tabel.)

however, if you´re also interested in that task, I found a solution using the java-snippet declaring a global variable in it (pseudocode):

global variable declaration:

ArrayList<String> concat_al = new ArrayList<String>();

method body:

for (int i=0; i<$$ROWCOUNT$$; i++) {
    if (Rowindex == i) {
        for (int j=0; j<$column with arrays to concat$.length; j++) {    
        concat_al.add($column with arrays to concat$[j]);
        }
    }
}

String[] concat = new String[$No_missing_molecules$];

for (int i=0; i<$No_missing_molecules$; i++) {
    concat[i] = concat_al.get(i);
    }

return concat;

 

cheers

sorry, I forgot to replace one variable by a general meaning:

String[] concat = new String[concat_al.size()];

for (int i=0; i<$concat_al.size()$; i++) {
    concat[i] = concat_al.get(i);
    }

return concat;

// the code will return the concatenation only in the last row...