locked
Importing CSV files with variable rows RRS feed

  • Question

  • I am trying to import csv files into SQL server.  The first row in the file contains identifier information (Id, Company, Date, File Type).  The second row contains the column headers.  The remaining rows contain the column data.  What I need to do is read the first row to determine the File Type and then build a table using the column headers and column data.  When I use SSIS and try to import the rows I end up with 4 columns which is correct for the identifier row but combines many of the column headers and column data entries as comma seperated values in column 4.  Any help would be greatly appreciated.

    Thanks,

    Bob

    Wednesday, February 22, 2012 8:41 PM

Answers

  • Hi Bob,

    use the Conditinal Split Transformation to generate a set of three flat files and operate on each to process according to the logic.

    A close example could be this post: http://www.sqlis.com/sqlis/post/Handling-different-row-types-in-the-same-file.aspx


    Arthur My Blog

    • Proposed as answer by Eileen Zhao Monday, February 27, 2012 7:51 AM
    • Marked as answer by Eileen Zhao Friday, March 2, 2012 7:34 AM
    Wednesday, February 22, 2012 10:30 PM

All replies

  • Hi Bob,

    use the Conditinal Split Transformation to generate a set of three flat files and operate on each to process according to the logic.

    A close example could be this post: http://www.sqlis.com/sqlis/post/Handling-different-row-types-in-the-same-file.aspx


    Arthur My Blog

    • Proposed as answer by Eileen Zhao Monday, February 27, 2012 7:51 AM
    • Marked as answer by Eileen Zhao Friday, March 2, 2012 7:34 AM
    Wednesday, February 22, 2012 10:30 PM
  • Do you have a finite set of expected file formats?

    Todd McDermid's Blog Talk to me now on

    Wednesday, February 22, 2012 10:57 PM