Page 1 of 1

Create file for every group of data:

Posted: Wed May 23, 2012 11:35 am
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.

Re: Create file for every group of data:

Posted: Wed May 23, 2012 1:35 pm
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