Create file for every group of data:

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
kumar444
Premium Member
Premium Member
Posts: 62
Joined: Wed Jan 12, 2011 10:01 am

Create file for every group of data:

Post by kumar444 »

Hi folks,
I have the following data. I can imagine doing this in loop but would take lot of time as there are many records. Is there any quick way of doing this in datastage? I know this can be acheived using shell. As i am poor in shell I want to see if this can be done in DS. Any help is greatly appreciated.

Code: Select all

order      File_name
7222245 7222245.pdf
7222245 7222245a.pdf
7222245 7222245b.pdf
7222245 7222245c.pdf
7222245 7222245d.pdf
7222250 7222250.pdf
7222250 7222250a.pdf
7222250 7222250b.pdf
I have to create files in the below manner using above records for every unique order i have to group the corresponding file names and put them in a seperate file.

Code: Select all

For example output for above set is :
7222245.txt
>>7222245.pdf
>>7222245a.pdf
>>7222245b.pdf
>>7222245c.pdf
>>7222245d.pdf
------------------------------------
7222250.txt
>>7222250.pdf
>>7222250a.pdf
>>7222250b.pdf
-------------------------------------
Note: Name of the file is Order.txt and the content is grouped file names.
-------------------------------------------
Kumar
wahi80
Participant
Posts: 214
Joined: Thu Feb 07, 2008 4:37 pm

Re: Create file for every group of data:

Post by wahi80 »

Sometimes it is easier doing in shell than DS, this is that time

Code: Select all

cut -d " " -f1 Order.txt | uniq > gdata
cut -d " " -f2 Order.txt > fdata

while read LINE
do
        grep $LINE fdata > $LINE.txt

done < gdata
Post Reply