creating a file xyz when the same file xyz is found empty

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
karrisuresh
Participant
Posts: 57
Joined: Sat Jun 09, 2007 1:14 am
Location: chicago

creating a file xyz when the same file xyz is found empty

Post by karrisuresh »

Hi One of my job's o/p is seq file xyz.csv,
My req is If the o/p file xyz.csv is empty,then I should be able to generate same file xyz.csv with another field format


xyz.csv field format(K1 is field name)
-----------
K1

new file format xyz.csv(If the above file is empty then it should be in this form)
-----------
x1,x2,x3

p,q,r,x,y,z

thanks a lot
Hi I have experience in parallel extender datastage I am ready to give/take help from other
hope we all help each other hand in hand
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

Your requirements description is somewhat confusing. If you have no data to satisfy the first format requirements, are you supposed to create the second format instead? Using the same data source or a separate data source? Using the same job or a separate job? Do you know before or after you attempt to create the first format?

A more complete description of the requirements and conditions will help to answer the request.

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
karrisuresh
Participant
Posts: 57
Joined: Sat Jun 09, 2007 1:14 am
Location: chicago

Post by karrisuresh »

FIrst of all Let me thank you for a prompt help,

to keep it simple ,my file name is xyz,it will never change,
if the first file xyz is having more than or equal to 1 record,then fine
else(ie if the file xyz has zero records),then I should produce a file with same above name xyz,but this time the format is different,
a header
a blank rec delimiter
a footer

eg:
x1,x2,x3,x4

p,q,r
Note-The new file we are gen is also an empty file,no need of recs only header
blank delmiter
footer


thanks once again
Hi I have experience in parallel extender datastage I am ready to give/take help from other
hope we all help each other hand in hand
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

I'm going to accept that when you say "empty file" you mean a file with header, empty record, and trailer. Is this correct?

Will only the header have to change format? Trailer and empty data record remain the same?

I think a sequencer could probably execute a basic routine or shell script that could easily determine whether or not the file is "empty", rename it and return empty/non-empty and the filename as a result to the sequencer. If not empty, run your job which processes the data. If empty, call another basic routine or shell script which replaces the existing header with the new one (they are both just strings).

Regards,
- james wiles


All generalizations are false, including this one - Mark Twain.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Code: Select all

if [ -z #filename# ] then
   echo "x1,x2,x3\n\np,q,r,s" > #filename#
fi
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