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.

Talend tFileList 1

Talend tFileList Example

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

Talend tFileList 2

The following screenshot shows the tFileList properties available in the components tab.

Talend tFileList 3

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.

Talend tFileList 4

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 option or Directories option. And also, checkmark the Include subdirectories option.

Talend tFileList 5

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.

Talend tFileList 6

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

Talend tFileList 7

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

Talend tFileList 8

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.

Talend tFileList 9

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

Talend tFileList 10

Here, we used the tLogRow to show the records.

Talend tFileList 11

Let me run this Talend tFileList job.

Talend tFileList 12

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.

Talend tFileList 13

Let me rerun the Talend tFileList job.

Talend tFileList 14

You can see the records from all the three text files.

Talend tFileList 15

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

Talend tFileList 16

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

Talend tFileList 17