Monday, May 11, 2015

How to Append Multiple File Using tFileList component !!

tFileList component iterates on files or folders of set directory and it retrieves a set of files or folders based on a filemask pattern.

In below job I have taken three input csv files(with same schema) they are as follows:--

Student_List1

student_id;student_name;student_branchid
101;Sameer Chowdhary;1
102;Aditya Tiwari;1
103;Gaurav Tiwari;1
104;Shashi Singh;1
105;Yogesh Mishra;5
106;Ankit Gupta;8
107;Mohit Sharma;9
108;Rajesh Soni;8
109;Rohit Sinha;1

Student_List2

student_id;student_name;student_branchid
110;Radha Singh;2
111;Richa Swankar;9
112;Santosh Tiwari;4
113;Gaurav Tiwari;1
114;Mohammad Singh;1
115;Prachi Mishra;5
116;Duddu Gupta;3
117;Mahi Sharma;9
118;Renuka Soni;6
119;Swati Sinha;1

Student_List3

student_id;student_name;student_branchid
120;Ravi Mahlotra;7

1. Select the component tFileList and tFileInputDelimited and  tFileOutputDelimited from the Palette and drag it into the job design window.

2. Connect tFileList component by Right click on the tFileList component, select Run -> Iterate
Connect this “Iterate” link to the tFileInputDelimited component.Then connect 
 tFileInputDelimited to by right click and selecr Row > Main and drag the line to tFileOutputDelimited component.



3. Click on the tFileList component properties and then click on “Directory” tab select the directory that contains the excel files by clicking on the “…” button.For example I have all three files in one folder named as Student_List.
In the "Files" column write the Filemask such as "student*" this means that the filename which starts from student that files will be only considered in tFileList .

4. Open the tFileInputDelimited component properties and set Property type  to “Built In”.
Under “File name / Stream” tab type tfilelist then press ctrl + space.
Select tFileList_1.CURRENT_FILEPATH.



5. Click on Edit Schema to provide the schema of the files. In the Popup window add three columns as shown in screenshot below.

6. Open the componnet properties of tFileOutputDelimited :--

Write the File Name by clicking .... button where you want to store your single csv file.
Tick append check box to append the data to existing file instead of creating new file every time.

Note: While running job for multiple files, All input files data will be appended to single file with this append check box.
Check include header so that single file will appear with header column.



Make sure you have multiple CSV files in your directory.
7. Click the “Run” button.
Now you will see all your files are processed one by one and loaded into the Single File.


Append_StudentList.csvstudent_id;student_name;student_branchid
101;Sameer Chowdhary;1
102;Aditya Tiwari;1
103;Gaurav Tiwari;1
104;Shashi Singh;1
105;Yogesh Mishra;5
106;Ankit Gupta;8
107;Mohit Sharma;9
108;Rajesh Soni;8
109;Rohit Sinha;1
110;Radha Singh;2
111;Richa Swankar;9
112;Santosh Tiwari;4
113;Gaurav Tiwari;1
114;Mohammad Singh;1
115;Prachi Mishra;5
116;Duddu Gupta;3
117;Mahi Sharma;9
118;Renuka Soni;6
119;Swati Sinha;1
120;Ravi Mahlotra;7

Result would be like above in excel format.

No comments:

Post a Comment