[resolved] How to create multiple output files based on a field from input?

One Star

[resolved] How to create multiple output files based on a field from input?

I have a need of creating multiple output files based on a value (column) from an sql input
My tMSSQLInput returns about 50,000+ rows in which where one of the columns value is the building_name
Building A 
Building B 
Building C 
....
I would like that all rows that have value "Building A" to end up in an excel file named "buildingA.xls", all rows that contain the value "Building B" should be in an excel file named "buildingB.xls" and so on.
I have been trying to use tLoop or tForEach along with tIterateToFlow but I am not sure that I know how to implement it.
Five Stars

Re: [resolved] How to create multiple output files based on a field from input?

There's probably a few ways you could do this.
How about...
A query that just reads the unique building names.
flow to iterate the result set.
This will put the building name on globalMap.
Use this to execute a second query for all data relating to the building name and then write this to a file using the globalMap value for the building name.
If this is not fast enough, you could write the entire data set to tHashOutput and then do the same thing from in-memory data.
One Star

Re: [resolved] How to create multiple output files based on a field from input?

Hi,
First take unique building_name using tuniqrow and connect to tFlowtoIterate and then connect iterate connection to your input file and
filter rows on every iterate. Your Job design will be like this
Use your iterate global variable "building_number" in tFilterRow & tOutputfile component

tInputFile--->tUniqRow--->tFlowToIterate------>tInputFileExcel------->tFilterRow------>tMap---->tOutputFile

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog