0
votes

I have a problem using the javascript step transformation.

I have only three steps:

1- Data Grid (with the dataset)

Input:

Col_1 | Col_2 | Col_3
   a      b      c
   d      e      f

2- Modified Java Script Value

var resultField = col1 + " " + col2 + " " + col3;

And resultField is the single Output field from the step

3- Text File Output

A simple csv where I need to export the result.

Expected Output 1 row with the result :

abcdef

Real Output 2 rows with splitted result:

abc
def

Thank you!

2
Can you please share the complete code - Hector Barbossa
Hi!, I have updated my question - Idir Ouhab Meskine
So that's your code? var resultField = col1 + " " + col2 + " " + col3;? And with this we should now know/guess/understand what's wrong with your code? Try adding \n at the end of the string (var resultField = col1 + " " + col2 + " " + col3 + '\n';) - Alon Eitan
I'm not telling that my code is wrong, my problem is that I don't know how to do it. I know how to concatenate strings with javascript, but I don't know how to concatenate more than one row at once with kettle. - Idir Ouhab Meskine

2 Answers

2
votes

Use your javascript (or calculator) to concatenate the columns on row 1, and then use the group by step to concatenate those multi-row results into one field.

So javascript gives you 2 rows: abc def

and after group by you get

abcdef

Whilst you can group across multiple rows in javascript, I wouldn't as it gets pretty messy.

0
votes

If i understood correctly your problem, you want to concatenate all the rows from the data grid in the javascript step. The only way i think you can do that is by dumping the rows in a temporary file and loading that file in the javascript step.