SSIS-Data in multiple .csv files to columns in same csv file

  • Hi Everyone

    I have the below problem,could anyone please suggest me a solution.

    file 1 has below data

    1.csv

    A

    B

    C

    2.csv

    E

    F

    G

    the data in the output file should be

    A E

    B F

    C G

    the separator in output file can be tab or ,

    could any one help?

  • avinash.818 (4/25/2013)


    Hi Everyone

    I have the below problem,could anyone please suggest me a solution.

    file 1 has below data

    1.csv

    A

    B

    C

    2.csv

    E

    F

    G

    the data in the output file should be

    A E

    B F

    C G

    the separator in output file can be tab or ,

    could any one help?

    Use a Data Flow task with a MERGE connector to pull the files into the same data stream. Then output to a new file.

    That's the best advice I can give you based on the information you've provided.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Hi Brandie,

    If I add a Merge Transform and Pull the Data into Destination,Data from each file Merges as one column in the output,what I need is a separate column for each file

    This is my requirement. I have Several files each with One-Column and Several Rows

    what I need is all the data is multiple files should go into one file with multiple columns

    one column for one file.....can you suggest?

  • avinash.818 (5/6/2013)


    Hi Brandie,

    If I add a Merge Transform and Pull the Data into Destination,Data from each file Merges as one column in the output,what I need is a separate column for each file

    This is my requirement. I have Several files each with One-Column and Several Rows

    what I need is all the data is multiple files should go into one file with multiple columns

    one column for one file.....can you suggest?

    The problem here is you don't have an ID to join on, so you can't use the MERGE JOIN.

    I think you'll need a script component as a transformation, where you read the two inputs and create one output row with two columns.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • an identity column against each row would serve the purpose.....

    you can use merge join then

  • Koen Verbeeck (5/6/2013)


    avinash.818 (5/6/2013)


    Hi Brandie,

    If I add a Merge Transform and Pull the Data into Destination,Data from each file Merges as one column in the output,what I need is a separate column for each file

    This is my requirement. I have Several files each with One-Column and Several Rows

    what I need is all the data is multiple files should go into one file with multiple columns

    one column for one file.....can you suggest?

    The problem here is you don't have an ID to join on, so you can't use the MERGE JOIN.

    I think you'll need a script component as a transformation, where you read the two inputs and create one output row with two columns.

    EDITING my response because I remembered what I meant originally.

    Not a MERGE Transform. I misspoke. It should be a UNION ALL transform.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Brandie Tarvin (5/6/2013)


    Koen Verbeeck (5/6/2013)


    avinash.818 (5/6/2013)


    Hi Brandie,

    If I add a Merge Transform and Pull the Data into Destination,Data from each file Merges as one column in the output,what I need is a separate column for each file

    This is my requirement. I have Several files each with One-Column and Several Rows

    what I need is all the data is multiple files should go into one file with multiple columns

    one column for one file.....can you suggest?

    The problem here is you don't have an ID to join on, so you can't use the MERGE JOIN.

    I think you'll need a script component as a transformation, where you read the two inputs and create one output row with two columns.

    EDITING my response because I remembered what I meant originally.

    Not a MERGE Transform. I misspoke. It should be a UNION ALL transform.

    A UNION ALL is the same as the MERGE transform, but without the sorting.

    It unions the data on a row basis, not a column basis (it's the same as in TSQL, you need to have the same columns).

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Koen Verbeeck (5/6/2013)


    Brandie Tarvin (5/6/2013)


    Koen Verbeeck (5/6/2013)


    avinash.818 (5/6/2013)


    Hi Brandie,

    If I add a Merge Transform and Pull the Data into Destination,Data from each file Merges as one column in the output,what I need is a separate column for each file

    This is my requirement. I have Several files each with One-Column and Several Rows

    what I need is all the data is multiple files should go into one file with multiple columns

    one column for one file.....can you suggest?

    The problem here is you don't have an ID to join on, so you can't use the MERGE JOIN.

    I think you'll need a script component as a transformation, where you read the two inputs and create one output row with two columns.

    EDITING my response because I remembered what I meant originally.

    Not a MERGE Transform. I misspoke. It should be a UNION ALL transform.

    A UNION ALL is the same as the MERGE transform, but without the sorting.

    It unions the data on a row basis, not a column basis (it's the same as in TSQL, you need to have the same columns).

    Given what information the OP gave us, that's what he wants.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Brandie Tarvin (5/6/2013)


    Given what information the OP gave us, that's what he wants.

    File 1:

    A

    B

    C

    File 2:

    E

    F

    G

    Union All gives us:

    A

    B

    C

    E

    F

    G

    Merge Join gives us:

    A E

    B F

    C G

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Hi Can you Generate AutoIdentity Number(adding new ID columne/through Script Component) for Each File Seperately.

    Then Apply Merge Join , Based on ID Column(this helps Join on RowNumber Position)

    example:

    File1

    Id Col

    1 A

    2 B

    3 C

    File 2

    Id Col

    1 D

    2 E

    3 F

    Merge Join On File1.ID = File2.ID

    So Final out put will be

    ID File1.Col File2.Col

    1 A D

    2 B E

    3 C F

  • AutoGenrating Identity solves,but the data is in Text file and there are around 700 files which needs to be processed

  • In several other packages, here's what I did. I had to actually do a Multicast to do derived columns. Then I pulled those columns together with a UNION ALL. The UNION did not require an identity. I know this because I just replicated what I've previously done.

    So you should be able to just put the multiple file sources into a Data Flow task and join them together with a UNION ALL. The trick is you need the same # of columns, in that order, and have the same metadata for each column.

    Easy Peasy, no identitifier required.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply