Use Filename as Part of Transformation

  • I am trying to take some console logs from an enterprise management application and import them so i can do some reporting with the data. The problem I have with the data is the fact that the files *do not* have the dates in them, they only have a time, but the filename contains the date.

    eg. 20030811.csv is the filename

    and the data partially looks like:

    RecIdColorAttribTimeType

    160DefaultDefault0:00:02Message

    1016DefaultDefault0:00:03Message

    I would prefer to import the data into my tables as a datetime.

    Does anyone have a method that will let me parse the date from the filename and concatenate it with my time to create a datetime field?

    Darren

  • This was removed by the editor as SPAM

  • Not sure how you are triggering the package. If you are calling it from a page or proc you could try this:

    Try sending the file name 20030811.csv as a global variable from the calling procedure. In your DTS create an active X script and from in there you should be able to parse out the date value from the global variable comine it with the time column and pour it into the correct column.

    Stupid question but is the file name alwys current date? If so just skip the Global and use date in the Active X script.

  • I do something similar.1 step Select The filename as a string and then save the datepart to a global variable.2nd step trasformation do an activeX for the column

    as

    DTSDestination("DateTime") = DTSGlobalVariables("GlobalFileDate") + " " + DTSSource("Time").

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

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