Creating and writing files depending on the input data

Sometimes it is required that multiple files are written from a single data source where the file name is dependent upon the data held within the row. This recipe shows how this can be achieved.

Getting ready

Open the jo_cook_ch08_0140_filesFromInputData job.

How to do it...

The steps for creating and writing files depending on the input data are as follows:

  1. Run the job, and you will see that the file dummy.txt has been created and populated with six rows.
  2. Open the tJavaRow component, and you will see that the move of data from input to output has already been performed.
  3. Add in the following code after the generated code:
    // test for change of input_row.key if (Numeric.sequence(input_row.key, 1, 1) ...

Get Talend Open Studio Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.