'Any solutions on splitting output file?

I'm a newbie here in Talend and what I am trying to do is to split different output file, here is an example of the file that I am working on...

File of Example

For example:

Whenever I see a column with a true value I need to produce different file of it including the row with the value of true.

So the output should be like this: output example

output example output example

Thanks in advance guys, hope someone could help me.



Solution 1:[1]

Here is a dynamic solution. Your input file should be sorted on "quoteName"

enter image description here

  1. tFileInput : read your file
  2. tFilterRow : filter on isLastItem : only "true" value (so you'll get only one row for each quoteName)
  3. tflowToIterate : convert your flow into an iteration : you'll have n iterations created (n being the number of distinct quoteNames).
  4. tFileInput : re-read your entire file in your current Iteration
  5. tFilterRow : filter on quote=((String)globalMap.get("row2.quote")) (with row2.quote being the value of your globalVariable created by tFlowToIterate)
  6. tFileOutput : output file. You can put something like : "C:/Temp/"+((String)globalMap.get("row3.quote"))+".txt" in order to generate your distinct files.

Use "Outline" view to get access to global variables created by tFlowToIterate.

Solution 2:[2]

Try simply run this in the terminal:

python folder_path\code\cmd_line.py test

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Corentin
Solution 2 Herivelton Andreassa