Combine flat files based on date in the file name in a folder using SSIS

  • We receive two or more flat files for a particular date for data to be loaded into the table.

    file names are as below

    ABC_2017-05-17_2000_bcd.csv

    ABC_2017-05-17_2100_bcd.csv

    ABC_2017-05-18_2000_bcd.csv

    ABC_2017-05-18_2100_bcd.csv

    ABC_2017-05-18_2130_bcd.csv

    ABC_2017-05-19_2000_bcd.csv

    ABC_2017-05-19_2100_bcd.csv

    ABC_2017-05-20_2000_bcd.csv

    ABC_2017-05-20_2100_bcd.csv

    I'm trying to combine files with the same date and rename the combined file for example: comb_ABC_2017-05-17_bcd.csv

    I cannot/not allowed load them one by one into the table. I would like to combine them before I load the data from combined file into database.

    Can someone help me do this? Appreciate your help!

  • do the file formats differ? Or are they exactly the same column definitions, just different names?

    -------------------------------------------------------------------------------------------------------------------------------------
    Please follow Best Practices For Posting On Forums to receive quicker and higher quality responses

  • Hi,

    I'm extremely sorry for the late reply. Thanks for looking at my post.

    File formats are same except the file names are different based on date of the file arrival.

    This is what I did.

    1. Script task to create an empty file with required file name

    2. Script task to read the first file contents into a variable

    Write the contents of the variable into the file created in step1

    3. Keep the script task created in step 2 in a for each loop container to loop through the folder for a particular date

Viewing 3 posts - 1 through 2 (of 2 total)

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