SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


For each loop through complex filenames


For each loop through complex filenames

Author
Message
Damian
Damian
SSCertifiable
SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)

Group: General Forum Members
Points: 7062 Visits: 1459
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
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)

Group: General Forum Members
Points: 221050 Visits: 25128
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.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Damian
Damian
SSCertifiable
SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)SSCertifiable (7.1K reputation)

Group: General Forum Members
Points: 7062 Visits: 1459
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum









































































































































































SQLServerCentral


Search