We can load the fixed length file In DFT using the Script component.
In this demo
we will see how to load this file in DFT using the script component transformation.
Below the file.
Mapping of this file
Name: 0-19
Mobile: 19-34
Address: 34-60
Table where we are storing this data.
Taking DFT
and taking Source as Flat file and creating the connection.
Now we are
taking the Script Component Transformation and selecting as transformation.
Click ok.
Now double Click on the script component
And Select
Input Columns.
Here we can
select the list of input columns.
There are
two types of Usage type ReadOnly (We
can’t modify the input) and other one is Read Write.
Now Come to
Inputs and outputs table and need to create the output column here.
Here we are
renaming the Input column name and creating the output column name.
Now come to the script tab and click on the edit script.
Writing the
below code in the script component.
We need to
write the code in the function Input0_ProcessInputRow
public override void
Input0_ProcessInputRow(Input0Buffer Row) { /* * Add
your code here */ string name =
Row.NMA.Substring(0, 19).ToString(); Row.Name =
name; string mob =
Row.NMA.Substring(19, 15).ToString(); Row.Mob =
mob; string emp_add =
Row.NMA.Substring(34, 25).ToString(); Row.EmpAdd
= emp_add;
} |
Now we are
taking the OLEDB destination and mapping the columns.
Now our
package is ready to run.
Before run see the records in the table.
Now running the package.
Package
executed successfully.
See the
records in the table.
Data loaded successfully.