I have an input file and I want to make "n" output files using distinct value.
I need n different files based on distinct values in Col1 with "H".
Any help in this direction would be vey helpful.
Solved! Go to Solution.
Here is the main job:
- tFixedFlowInput is here to mimic your input file:
- tJavaRow set the needed context variables (filename and line):
output_row.line = input_row.line; output_row.type = input_row.line.substring(0, 1); context.line = input_row.line; if(output_row.type.equalsIgnoreCase("H")) context.filename = input_row.line.substring(1, 5);
- tFilterRow is here to exclude header lines from result:
- tRunJob call the external job called "writer" (check the option "Transmit whole context" on this component to transmit the context variables "filename" and "line" you to define for both jobs)
Here is the external subjob "writer" :
- tFixedFlowInput is here to convert context variable "line" into a flow (required for the next component):
- tFileOutputDelimited is here to write the flow into the current file (designed by filename context variable (check option "Append" to write at the end of the file):
Thank you very much!! You are the best!
I have trying do the same job but i have errors. Could you tell me why please?
If you just want to split the input file based on row count. Then Use tFileOutputDelimited.
Go to Advanced setting and tick (Split output in several files) and you can mention number of row you need in each output file.
I have the similar scenario but only the input is different, where the keywords is after the records. How do I achieve the similar output?
HZARA 123 <-- the Hxxxx indicator is after the data
HCUSTO456 <-- the Hxxxx indicator is after the data
Output just like una:
You should have a look to tMemorizeRows / tJavaFlex to solve your case.
Have a look to the tMemorizeRows documentation which contains an example.
I ran across your reply while working on a similar problem. But there is something I don't understand. Your example works as it should, but if instead of using a subjob for the tFileOutputDelimited, you filter directly to the tFileOutputDelimited, then only one .txt file is generated and the file is named ".txt", as if the context.filename is blank.
What is different about putting the output in a subjob vs. after the filter?
Introduction to Talend Open Studio for Data Integration.
Practical steps to developing your data integration strategy.
Create systems and workflow to manage clean data ingestion and data transformation.