For each loop through complex filenames

  • Hello

    There may be a fundamentally different approach required here - not sure what though!

    I have a file structure that will always be of the form:

    IN_<reference>_DDMMCCYY_post.txt

    reference will differ every time
    DDMMCCYY is a date and should also differ every time - although, it will always be 8 digits in this format

    There will be a number of files of this format within a folder
    There could be other files of a different format

    I only want to read in the files of this format then write the data to a table

    So, I was think of an SSIS For each loop through the folder looking for file of this form
    Within the loop container, it will write the data

    Really struggling with the expression though

    I was hoping something like: "IN_*_????????_post.txt" might work
    It validates but doesn't return anything

    These expressions work:

    "IN_*.txt"
    "*_????????_*.txt"

    Any thoughts?

    Thanks

    - Damian

  • DamianC - Thursday, March 1, 2018 10:54 AM

    Hello

    There may be a fundamentally different approach required here - not sure what though!

    I have a file structure that will always be of the form:

    IN_<reference>_DDMMCCYY_post.txt

    reference will differ every time
    DDMMCCYY is a date and should also differ every time - although, it will always be 8 digits in this format

    There will be a number of files of this format within a folder
    There could be other files of a different format

    I only want to read in the files of this format then write the data to a table

    So, I was think of an SSIS For each loop through the folder looking for file of this form
    Within the loop container, it will write the data

    Really struggling with the expression though

    I was hoping something like: "IN_*_????????_post.txt" might work
    It validates but doesn't return anything

    These expressions work:

    "IN_*.txt"
    "*_????????_*.txt"

    Any thoughts?

    Thanks

    I'd stick with your simple version ("IN_*.txt") on the FEL and add a script task as step 1 within your FEL to set a package-scoped variable to indicate whether to process the file (YES/NO, 1/0, TRUE/FALSE or whatever).
    Use precedence constraints after the script task to control whether or not the 'current' file gets processed.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Ah right, yes that makes sense Phil

    About to leave for the day so i'll give that a go in the morning

    Much appreciated

    Damian.

    - Damian

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

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