0

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!

Idir Ouhab Meskine
  • 587
  • 1
  • 9
  • 23
  • 1
    Can you please share the complete code – Hector Barbossa Jul 13 '16 at 21:08
  • Hi!, I have updated my question – Idir Ouhab Meskine Jul 13 '16 at 21:15
  • 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 Jul 13 '16 at 21:21
  • 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 Jul 13 '16 at 21:38

2 Answers2

2

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.

Codek
  • 5,114
  • 3
  • 24
  • 38
0

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.