SSIS - how to split rows (not columns) -


i have file 100 rows , 20 columns, first 2 rows text , 98 others numbers. there no headers - need combine row1 , row2 have header.

i want split row 1 one output , row 2 output combine col1 row1 , row2, combine col2 row1 , row2, combine col3 row1 , row2 etc 20 columns create new headers. after combining, use union write new output file have 99 rows: row 1 text new headers , remaining 99 numbers.

does ssis allow me that? know can conditional split column values there way split values based on row or row number? can conditional split work rows?

thx

i can think of 2 solutions.

  1. you create script component of type "source" reading file, way can control row outputs, reading on them. removes use/benefits of connection manager/flat file component, not recommend first choice.

  2. you create short script component of type transformation, , alter first few rows (assuming reading proper line order).

for #2, how (you can filter out rowindex 0): enter image description here within script component make sure following setup (creating output column 'rowindex' , having input columns marked 'readwrite'):

enter image description here enter image description here after setup, script needs this:

public class scriptmain : usercomponent {     public static int rowcount = 0;      public override void input0_processinputrow(input0buffer row)     {         if (rowcount == 0)         {             // store row's information             string column0 = row.column0;             string column1 = row.column1;              // set index (0), , make fetch next row             row.rowindex = rowcount++;             row.nextrow();              // next row (the second), combine columns.             row.column0 = column0 + " " + row.column0;             row.column1 = column1 + " " + row.column1;         }         // increment , store each following row.         row.rowindex = rowcount++;     } } 

hopefully helps.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -