Tuesday, March 26, 2013

Flat file destination with Header and Detail rows

The expected output of the file is (Fixed header and details tab limited)


## Import File v:2.0      
## pre-process header.   
## D:2013-03-14 12:59:23        
Key Product Name          
71 Hollywood Flesh Latex         
108 The Wizard of Oz Wicked Witch Adult Costume         
204 Economy Ninja Sword         
214 Sabre Tooth Bracelet         
220 Monk's Cross         
322 Looney Tunes Sylvester the Cat Adult Costume 




To generate the output we have to use two flat file destination connections and both connection string should map to the same destination variable(use the variable).


Please follow the below steps to generate the file.


step 1. Create the dataflow task and use script component as source to generate header text.


use below script to generate the header rows




public override void CreateNewOutputRows()
    {
        /*
          Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
          For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
        */
        Output0Buffer.AddRow();
        Output0Buffer.Header = "## Import File v:2.0 ";
        Output0Buffer.AddRow();
        Output0Buffer.Header = "## pre-process header";
        Output0Buffer.AddRow();
        Output0Buffer.Header = "## D:2013-03-14 12:59:23;

    }



Step 2 . add flat file destination to generate the output file and make sure to click override the data in the file check box



Step 3 . use oledb source connection to get the details rows.



Step 4. Add flat file destination to generate the output file with tab limited and make sure to uncheck overwrite data in the Flat file destination Editor  ( By unchecking the box will make sure the header rows are not overwrite)

No comments:

Post a Comment