Check for a valid File name Format
HI Gurus, I have .dat flat files to be loaded into the database the file name format agreed is in the format below XXXYYY_ZZZ.dat is it possible to check if the file name is in not in the correct format for example one of the charterer is missing from the file name and raise an alert and process the next file ?
September 6th, 2012 10:19am

I presume you have to loop through a set of files. You can try this approach: In the for loop, extract your file name into a variable. Select this variable and set "RaiseChangedEvent" flag to true. What this will do is it will raise an event everytime the value of the variable is changed. In the for loop it will be changed everytime we set it with a new file name. Now go to eventhandlers and implement event handler "OnVariableValueChanged". This is the event handler which will handle the above event. Use a simple .net component to check if the value if the variable is in expected format and then send a notification. Check this post where Jamie has explained the RaiseChangeEvent. http://btsbee.wordpress.com/
Free Windows Admin Tool Kit Click here and download it now
September 6th, 2012 10:30am

There's not much you can check for in the format you've provided. As far as I can see, we can check that the string is 14 characters long, has an underscore at position 7, and ends with ".dat". What you can do is check for those three things in a precedence constraint. (This requires that you have a task that executes first, regardless of the file name - if you don't, use an empty Sequence Container to "start" your control flow.) Create such a precedence constraint and attach it to a Send Mail Task, or whatever other process you want to have happen on an error. Edit the precedence constraint, and change the type to "Expression and Constraint". Use an expression similar to: (LEN(@filename) != 14) || (SUBSTRING(@filename, 7, 1) != '_') || (LOWER(SUBSTRING(@filename, 11, 4)) != '.dat') You'll also then have to make the precedence constraint attached to the "real" control flow (that processes the file) have an expression opposite to the above, so it only gets executed if the filename variable is in the right format. Talk to me now on
September 6th, 2012 10:52am

Hi Todd, thanks for the reply my file name is AVAN2012081411402400086199_000001.csv i have to check if format is correct before loading it to the tables if not send an alert
Free Windows Admin Tool Kit Click here and download it now
September 6th, 2012 12:50pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics