Search

1. Talend – Merge multiple files into single file with sorting operation.



Scenario: Merging multiple input sources into a single target along with the file names with a additional column and sorting operations on all files with in the flow
The snapshot below shows the overall mapping.

As a source we have taken tFileList which will pull all our source files from the specified directory, then tFileInput Component will read all files one by one. In source file path you have to specify the global variable which holds the address of the current file in process using–

((String)globalMap.get(“tFileList_1_CURRENT_FILEPATH”))

Later tMap is used to assign one extra column which holds the name of the file and again name of the file is to be retrieve using global variable in our case it is

((String)globalMap.get(“tFileList_1_CURRENT_FILE”))

After
completion of first job we fire a onSubJobOk trigger to do our rest work.

now,
        tBufferInput will hold all the source file data at once and later tBufferInput will pull all the buffered data produced by tBufferOutput.
Finally, tSort Component will sort all the three source file data using some column as a key and tFileout- component will produce the final output.
that’s all, now you can create a job and simply run it.