Issue with Splitting of file

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
mdtauseefhussain
Participant
Posts: 38
Joined: Mon Feb 27, 2006 10:34 pm
Location: Chennai
Contact:

Issue with Splitting of file

Post by mdtauseefhussain »

HI! All
Iam running this script for splitting the file in command stage ,attacth a timesatmp to it and then conver it to .tmp extension

cd /home/staff/thussain
Prefix=Z_PRICE_NEW_`date "+%Y%m%d%H%M%S"`
split -3000 -a 5 /home/staff/thussain/Z_PRICE_NEW.txt $Prefix
find . -name "$Prefix*" -print | {
while read FILE;
do
mv $FILE $FILE.tmp
done
}
example out put
Z_PRICE_NEW_20070517014630aaaac.tmp
Z_PRICE_NEW_20070517014630aaaaa.tmp.tmp

but some files are coming with tmp extension twice ,and any on tell me how to resolve this issue..

Thanks in Advance

Regards

Tausif
Mohammed Tausif Hussain Sheikh
Cognizant technologies,Perungudi
Chennai
maheshsada
Participant
Posts: 69
Joined: Tue Jan 18, 2005 12:15 am

Post by maheshsada »

Please use the following code, which split the files and changes the output file with the required format

TEMP_FILENAME="U_D-1_$DATE_YYYYMMDD"_

TEMP_DATA="NED1_DATA"

##Split the File
split -a 4 $WORKDIR/NED1.csv $WORKDIR/$TEMP_DATA

##Move all the Filename that has been created while splitting into NED1_files.txt
ls $WORKDIR/$TEMP_DATA* > $WORKDIR/EDWLoadExtractNED1_files.txt

i=1

##Attach Sequence to each generated File and rename the File to the required format

for FILE_NAME in `cat $WORKDIR/EDWLoadExtractNED1_files.txt`
do
j=`echo $i |awk '{printf "%04ld",$1}'`

FILE="$TEMP_FILENAME$j"

mv $FILE_NAME $FILE

i=`expr $i + 1`

done

regards
Magesh S
mdtauseefhussain
Participant
Posts: 38
Joined: Mon Feb 27, 2006 10:34 pm
Location: Chennai
Contact:

Post by mdtauseefhussain »

But what is the issue with the existing script ,it work fine when the file is is smaall,its is throwing this issue only whenthe file is big..
Mohammed Tausif Hussain Sheikh
Cognizant technologies,Perungudi
Chennai
maheshsada
Participant
Posts: 69
Joined: Tue Jan 18, 2005 12:15 am

Post by maheshsada »

I have tested your script with 20000 rows its working fine, can you tell how much big is ur file

Magesh S
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

:?
Why is this on a DataStage forum?
Ought it not to be on a UNIX or shell scripting forum?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
mdtauseefhussain
Participant
Posts: 38
Joined: Mon Feb 27, 2006 10:34 pm
Location: Chennai
Contact:

Post by mdtauseefhussain »

The file which is causing the issue contains 700000 records..
Mohammed Tausif Hussain Sheikh
Cognizant technologies,Perungudi
Chennai
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

That's not many, unless each is Megabytes in size.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply