Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
rajesh90
Contributor
Contributor

Create multiple Output files based on Input Data

Hello All,

I'm looking to write multiple output files based on the input data.

The sample data in my input csv file looks something like below,

NEWYORK,1

NEWYORK,2

BERLIN,1

BERLIN,2

BERLIN,3

TOKYO,1

GERMANY,1

GERMANY,2

GERMANY,3

GERMANY,4

What I want is to create multiple output files like below,

NEWYORK.csv

BERLIN.csv

TOKYO.csv

GERMNANY.csv

The above files should only contain the data of the respective countries. Ex. NEWYORK file only contains, NEWYORK data.

The number of countries can keep changing.

Can you help to provide a solution for this.

Thank you.

Labels (3)
1 Solution

Accepted Solutions
Mahamoutou
Contributor III
Contributor III

You could these below steps to get job done.

1-- a whole job

0695b00000If64SAAR.png2--input file

0695b00000If66EAAR.png3--tUniqRow to get unique value of the city column

0695b00000If66dAAB.png4--tFlowToIterate to make Talend iterate through those unique city values

0695b00000If66xAAB.png5--Again input file

0695b00000If66EAAR.png6--tFilterRow to filter out rows based on the current iteration value ( You get the current iteration city value from the Outline view >> TFlowToIterate ((String)globalMap.get("city_var")) ).

0695b00000If67CAAR.png7--output files, make sure you put again this variable + ((String)globalMap.get("city_var")) +".csv" after your directory path

0695b00000If67MAAR.pngand you are done.

View solution in original post

2 Replies
Anonymous
Not applicable

Hi

You need to iterate each row and set a dynamic output file name. eg:

tFileInputDelimited--row1--tFlowToiterate--tFixedFlowInput--main--tFileOutputDelimited

on tFixedFlowInput: generate the current record.

on tFileOutputDelimited, set a dynamic output file name:

"D:/file/"+(String)globalMap.get("row1.columnName")+".csv"

 

note: columnName is column name of the first column defined on tFileInputDelimited

 

Regards

Shong

 

Mahamoutou
Contributor III
Contributor III

You could these below steps to get job done.

1-- a whole job

0695b00000If64SAAR.png2--input file

0695b00000If66EAAR.png3--tUniqRow to get unique value of the city column

0695b00000If66dAAB.png4--tFlowToIterate to make Talend iterate through those unique city values

0695b00000If66xAAB.png5--Again input file

0695b00000If66EAAR.png6--tFilterRow to filter out rows based on the current iteration value ( You get the current iteration city value from the Outline view >> TFlowToIterate ((String)globalMap.get("city_var")) ).

0695b00000If67CAAR.png7--output files, make sure you put again this variable + ((String)globalMap.get("city_var")) +".csv" after your directory path

0695b00000If67MAAR.pngand you are done.