Page 1 of 1

Extract date part from file name

Posted: Tue Sep 27, 2005 11:27 pm
by srekant


Hai

I have a scenario where i have to strip of date part from the file name

Ex:
Input
method_yyyymmdd.csv

Output
yyymmdd

and want to use it as a default value for one of the column in my target.


Any ideas how to achieve this.

Posted: Wed Sep 28, 2005 12:55 am
by ashwin2912
Use this in a transformer:
Input [8,8]

Or in Modify stage:
substring(8,8)


Now, How will you get the filename into a transformer/modify?
That would depend how are you reading this file...if you are using job parameters you can use it with ease.

Posted: Wed Sep 28, 2005 1:19 am
by srekant
we are using parameters can u guide on how to get this into a transformer.
using cut command in unix i am able to seperate the date part from file name and direct it to another file.

Posted: Wed Sep 28, 2005 3:41 am
by dsxdev
hi Srekant,
if you are using Job parameters then you need to pass the date part in the file name as Job parameter.

now it depends on how you are invoking your job if it is through a unix script

then use cut command to get date, which you have already done it.
When you invoke your job using dsjob utility pass this date value as a job parameter value as

JobParam=dd-mm-yyyy , i.e as name=value pair.

This job parameter can be used in your transformer.
In transformer column derivations on right click you can choose Job Parameters and from the list pick the job parameter.

Thus you can access the parameter value.

Other wise may have to use job Control or sequencer to pass the date value to the job as a parameter.

Posted: Wed Sep 28, 2005 9:36 am
by kumar_s
Hi,
You can directly use the parameter in transformer and use Index() funciton to split the date alone. ("_" can be used to isolate the date)

regards
kumar

Posted: Wed Sep 28, 2005 10:36 am
by roy
Hi,
What DS version your on?
If 7.5 or better yuo can use a sequence job to run a command returning the file name and use User Variable stage to define a variable holding the date by using basic routines and pass this variable as a parameter to your job.

If your using automaticly handle activities that fail you'll probably need to use a server job to return this info via user status and use that as the parameter value.

IHTH,