Talend tFileList

The Talend tFileList component helps you to iterate and read multiple files. If we want to load multiple files from a source whose metadata is the same, then we can use this Talend tFileList component.

To demonstrate the Talend tFileList, we will read three text files and load the data from those files into another text file. The following screenshot shows you the data inside one text file.

Sources Files in the Folder

Talend tFileList Example

First, drag and drop the tFileList into the Job design space.

add Talend tFileList to workflow to read multiple files from the list

The following screenshot shows the tFileList properties available in the components tab. Within the Directory, we have to select the Directory or folder that holds the required files. Let me click on the … browse button and select the Customers folder.

Choose Folder or Directory

Under the Talend FileList type, we have three options. If we have only files, then select the first option. When we have subdirectories, select both options or the Directories option. Also, checkmark the Include subdirectories option.

Within the Files section, click the Add button and choose the Filemask. Here, we used the *.txt because we want to read all the text files within this folder. If you want all the files *.* (first * for all the files, and the second star for all file extensions).

Use the order by section to change the order of file selection. For now, we choose the order by options by file name.

Use *.txt to choose the multiple files

Next, drag and drop the tFileInputDelimited to read data or records in each text file.

Connect Talend tFileList to tFileInputDelimiter to read multiple files from the list

Click on the Edit Schema button and add the Column names, Data type, length, and Precision.

Click the Schema to check the columns

To read one file, we generally choose that file within the File name/Stream section. However, in this scenario, we have to read multiple files, and our filenames are coming from the Talend tFileList. So, when you type t and click control+space, you get the following options. Please select the tFileList1.current_filepath. If you want the file name, then choose the file name.

Add File Name in Talend tFileList to read multiple files from the list

Please check all the other options of the File input delimited such as field separator, header row, footer row, and row separator.

Next, we used the tLogRow to show the records. Add the tLogRow to the workflow and connect to the tFileInputDelimited. Next, within the tLogRow component tab, choose the Table option. Let me run this Talend tFileList job.

Run the Talend tFileList Job to read multiple files from the list

From the above screenshot, you can see all the records. Let me replace the tLogRow with tFileOutputDelimited, and create a new file name with txt extension.

As we are loading data from multiple files, we have to choose the Append option. Next, we need the Header, so we checkmark the Include Header option.

Configure the output text file

Let me rerun the Talend tFileList job.

Run Talend tFileLis Job t to read multiple files from the list and save in text

You can see the records from all three text files.

Result Text

Let me change the Talend tFileList Order action from ASC to DESC (descending), and delete the CustomersFileList text file.

Talend tFileList append option to read multiple files from the list

Now you can see the records stored in a different order.

Final Text