Passing multiple filenames one after another

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Passing multiple filenames one after another

Post by mac4rfree85 »

HI Guys,

I have multiple files in a location. Now i need to process each file one after the another.

So, i need to pass the file names one after the another to a sequence.

Can you guys help me with this.

Cheers!!!!
Mac4rfree
vinothkumar
Participant
Posts: 342
Joined: Tue Nov 04, 2008 10:38 am
Location: Chennai, India

Post by vinothkumar »

Get all the file names through execute command stage. Use loop stage to process all files one by one by sending the file names.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What have you tried? That's exactly what the Start/End Loop stages are for, all you need to do is build them a delimited list of the filenames first.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post by mac4rfree85 »

I created a Execute command stage with "ls /path/Text*.txt" command in it.
Now How to pass it to the Start Loop Activity stage?
Mac4rfree
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

That by itself won't work as the list needs to be delimited. Typically you would use a User Variables Activity stage to generate the list and your O/S should have an "m" option (off the top of my head) to return your list of filenames comma delimited.
-craig

"You can never have too many knives" -- Logan Nine Fingers
rameshrr3
Premium Member
Premium Member
Posts: 609
Joined: Mon May 10, 2004 3:32 am
Location: BRENTWOOD, TN

Post by rameshrr3 »

Is the order in which files were created in the directory important ?

one possible option is to use

Code: Select all

ls -m /path/Text*.txt
And in an user variable stage use

Trailing field marks from command output need to be removed or else they can create problems..

Code: Select all

uv= FileListConvert(@FM,"",ExecCmd.$Command_Output) 
use this variable in the start loop , specifying comma as the delimiter.


Disclaimer : Some commands may not behave the same way in all platforms. Use discretion
Post Reply