Sample Mapping in talend

Requirement is below:


We have Source file emp.txt that contain below data.

Id,Name,Sal,Dept_No
1,Ankit,30000,10
2,Swati,42000,20
3,Rupali,35500,10
4,Yash,50200,20
5,Kavita,80000,10

We want output file  that contains only dept_no =20 as out.txt as below:

Id,Name,Sal,Dept_No
2,Swati,42000,20
4,Yash,50200,20


Step to perform this:
  1.     In Repository Right Click on Job Designs and Select Create job.                                                                 
                                                                                               
  2. Give the name of the job, whatever is required and Click on Finish.
    Now we can see we have Active  Design Area, and at the Left of Job Designs we have small Arrow or Plus symbol, that shows inside jobs.                                                                                                                                                                              
                                                                                                                                                                                                                  
  3. Click on that Arrow Symbol and Double Click on job. Now we can design job by using component.       
  4. We can find all required Component from Top Right where we have Palette tab, Give the name of Component and press Enter                                                                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          As by typing tfileInput, it will show all Component from list that contains that word.

    For txt or csv file we use tFileInputDelimited Component.                                                               

  5. Drag Component at design area from Palette list.                                                                          
  6. Double Click on Component, at belowwe can see properties of Component and change them.                                                                                                                             

  7. By Clicking on Edit Schema in Properties we can create schema that is required for our requirement                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        As we can see Initially Schema is blank. We can create column by Clicking  Green + tab, and rename column as per requirement, just by selecting, and can set DataType and Length as well.                                                                                                                                                                                                  
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Now Click Ok         
    In File name/ Stream we can provide the path of the input File.
    I am placing my Input File at Input Folder in C drive


    tlogRow Component is used to see output at any level in Job.

  8. Drag tlogRow component from Palette.

      
    To pass data from any component to any other Component, Right Click on that then Select Row, Click on Main and Finally move Cursor to next component then Click on that Component.                                                                                                                 
  9. It will look like below:                                                                                                                       

                                                                                                                              
  10.  Save job with CTRL+S, and to see O/P run the job by Clicking Run button from Top.                                                                                                     
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
  11.  Now to filter records for specific department no. we can use Component tFilterRow from Palette.                                                                                                                        
  12. Pass Main rows to Filter Component by previous component.                                                             
  13. Double Click to change component tFilter properties.                                                                              
  14. Initially in Conditions block its blank. By Clicking + button we can add condition.                                        
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  15. Change the condition as per requirement, by choosing InputColumn name from drop down list. In Operator drop down we have conditions like(Equal, Not Equal, Greater ets). For Value we can set any Value. For decimal and doubal just put the value. For String we need to put value in quotes.(“value”).                                                                                          
  16. For our case condition will look like below:                                                                                                

                                                                                    
  17. We can again put a tLogRow to see O/P.                                                                                             
  18. Now to store O/P in a txt file use Component tFileOutputDelimited from Palette. We just need to set path of output File.                                                                                                                                      
                                                                                                                                        


  19. Run the job and we can see output file as required.  
    We can deactivate tLogRow, just by Right Click on that component and Selecting Deactivate tLogRow, because it’s just to see result. 

No comments:

Post a Comment