Extra comma on the end of the loop

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
hsahay
Premium Member
Premium Member
Posts: 175
Joined: Wed Mar 21, 2007 9:35 am

Extra comma on the end of the loop

Post by hsahay »

Since I don't see this as resolved...I'm continuing this thread..

Moderator: Sorry, no - you get your own post. If anyone wants to see "this thread" click here.

Please let me know, how to solve the issue of extra comma on the end of the loop.

problem is
I have listed files in directory using ls *.txt|tr '\n' ','
to get abc.txt, def.txt,xyz.txt,

Each file name is passed as a parameter to the job.

After processing xyz.txt, loop tries to read the next value as there is comma after it and as there is none my sequence fails.

I also tried ls -m *.txt which gives me output as abc.txt, def.txt, xyz.txt which doesn't help in my case because my input to the
job will be /source/data/ abc.txt

As there is a space after data/ my command fails.

Ant insight would be great. Thanks.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Why not use a Nested Condition within the loop to verify that the $Counter activity variable is not empty?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If you have an "extra" character at the end of a string, simply trim it. You can substring out one less than the length of the string or do the same with the Left() function. For the "ls -m" approach, I don't recall ever seeing it add an extra space in the delimited list, what UNIX are you running? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply