You are on page 1of 8

Example of File Source Definition in Informatica

Problem Statement :
Create a mapping to load data from csv file containing employee data with the help of File Source Definition Transformation into EMP Table. Field information can be found in the header of file.

Source Data:

File Name :employee.dat File Format: csv file File Location : $$PMSourcFileDir

File Data: EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPT 1,JOHNSON,ADMIN,6,12/17/1990,18000,null,4 2,HARDING,MANAGER,9,2/2/1998,52000,300,3 3,TAFT,SALES I,2,1/2/1996,25000,500,3 4,HOOVER,SALES I,2,4/2/1990,27000,null,3 5,LINCOLN,TECH,6,6/23/1994,22500,1400,4 6,GARFIELD,MANAGER,9,5/1/1993,54000,null,4 7,POLK,TECH,6,9/22/1997,25000,null,4 8,GRANT,ENGINEER,10,3/30/1997,32000,null,2 9,JACKSON,CEO,,1/1/1990,75000,null,4 10,FILLMORE,MANAGER,9,8/9/1994,56000,null,2 11,ADAMS,ENGINEER,10,3/15/1996,34000,null,2 12,WASHINGTON,ADMIN,6,4/16/1998,18000,null,4 13,MONROE,ENGINEER,10,12/3/2000,30000,null,2 14,ROOSEVELT,CPA,9,10/12/1995,35000,null,1

Target Data:
EMP_ALL Table Data:

EMPNO

ENAME 1 JOHNSON 2 HARDING 3 TAFT 4 HOOVER 5 LINCOLN 6 GARFIELD 7 POLK 8 GRANT 9 JACKSON 10 FILLMORE

JOB ADMIN MANAGER SALES I SALES I TECH MANAGER TECH ENGINEER CEO MANAGER

MGR 1/6/1900 1/9/1900 2 2 6 9 6 10

HIREDATE 12/17/1990 2/2/1998 1/2/1996 4/2/1990 6/23/1994 5/1/1993 9/22/1997 3/30/1997 1/1/1990 9 8/9/1994

SAL 18000 52000 25000 27000 22500 54000 25000 32000 75000 56000

COMM 0 300 500 0 1400 0 0 0 0 0

DEPT 4 3 3 3 4 4 4 2 4 2

11 ADAMS 12 WASHINGTON

ENGINEER ADMIN

10 6

3/15/1996 4/16/1998

34000 18000

0 0

2 4

Sample Data for above problem can be get from here

Solution:
Steps to Import File Source Definition :
Prerequisite: To import Source Definition for file type ,you need to first copy the sample File on the machine where you are using Informatica Client. Or you can create Source Definition manually as well. In Informatica power center , first select Source Analyzer by clicking on below option

Click Sources > Import from File

File Source Definition Transformation in Informatica Step 1

It will open the Open Flat File dialog box , select the employee.dat file to be used as source Definition.

Once you select file , it will show Flat File Import Wizard Step 1 of 3 wizard. You will see content of file here.

o o o

Choose the Flat File Type as Delimited Enter Filename as employee_data Check Import field name from first line box , to automatically add field name in source Definition.

Note: You will notice that Start import at row automatically set to 2 from 1.

Click on next.

File Source Definition Transformation in Informatica Step 3

Flat File Import Wizard Step 2 of 3 wizard will appear.

o o o o

Select the Delimited:Set the Delimiter as Comma Treat Consecutive Delimiters as One: If selected, the Flat File Wizard reads one or more consecutive column delimiters as one. Otherwise, the Flat File Wizard reads two consecutive delimiters as a null value. Treat Multiple Delimiters as AND: If selected, the Flat File Wizard reads a specified set of delimiters as one. Escape Character: Character immediately preceding a column delimiter character embedded in an unquoted string, or immediately preceding the quote character in a quoted string. When you specify an escape character, the Integration Service reads the delimiter character as a regular character. This is called escaping the delimiter or quote character.

o o o

Remove Escape Character From Data: This option is selected by default. Clear this option to include the escape character in the output string. Use Default Text Length: If selected, the Flat File Wizard uses the entered default text length for all string datatypes. Text Qualifier: Quote character that defines the boundaries of text strings. Choose No Quote, Single Quote, or Double Quotes. If you select a quote character, the Flat File Wizard ignores delimiters within pairs of quotes.

File Source Definition Transformation in Informatica Step 4

Click next. Flat File Import Wizard Step 3 of 3 wizard will appear. You will see Port name and its data type will be automatically added in the Source Definition.

o o o

Name: Port name that you want to appear for each column. If you select Import Field Names from First Line, the wizard reads the column names provided in the file instead. Datatype: Column datatype. Select Text, Numeric, or Datetime, and then enter the appropriate Length/Precision, Scale, and Width. For numeric columns, Precision is the number of significant digits. The Flat File Wizard ignores the width for numeric columns in delimited files.

For Text columns, Precision is the maximum number of characters contained in the source field or the target field. The Flat File Wizard ignores the precision when reading text columns in or writing text columns to delimited files.

By default, the Flat File Wizard enters the same value for both Precision and Width. You can change the value of the precision or width, but the Flat File Wizard only lets you define the precision to be greater than or equal to the width.

Note : Double check the data type for the Datetime related fields. Click finish to create Flat File Source Definition. You can edit the properties this source Defintion In properties Tab , Select Date,time Format as per your input file.

Below are the steps to create full mapping.

Create a new mapping m_file_Source_Definition_example by Go to toolbar -> click mapping-> Create Drag Source (employee_data) from FlatFile node and Target (EMP_ALL) to the mapping. It will automatically add the SQ_employee_data related employee_data Source Definition. Now connect all the required port from SQ_employee_data to EMP_ALL Target Click on Mapping ( from tool bar) -> then Validate ( to validate the mapping) Now save the mapping ( by clicking on Repository-> Save or you can also press Ctrl+S) Generate the Session s_file_Source_Definition_example in workFlow Manager. edit the session, for SQ_employee_data

o o o

Set Source filetype as Direct. Set Source file directory as $PMSourceFileDir\ or other directory where file is placed Set Source filename as employee_data.dat

File Source Definition Transformation Session Properties 4

Over all Mapping:

File Source Definition Transformation in Informatica Full Mapping

So, in this article we have gone through step by step example of File Source Definition Transformation in Informatica mapping, learnt the step to add Source Definition for file Type , configure the port , properties , adding Source Definition mapping properties in mapping task. http://www.tecktricks.com/example-of-file-source-definition-in-informatica-example-1/

Also Refer: http://www.tecktricks.com/step-by-step-of-creating-file-target-definition-in-informatica-and-using-it-ininformatica-mapping/ http://www.tecktricks.com/dynamically-split-target-flat-file-in-informatica/ http://www.tecktricks.com/difference-between-relational-lookup-and-flat-file-lookup-transformation-in-informatica/

http://www.howtointegratedata.com/category/informatica/informatica-transformations/

You might also like