Page 1 of 1

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

Posted: Tue Feb 08, 2011 7:25 am
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

Posted: Tue Feb 08, 2011 7:49 am
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,

Posted: Tue Feb 08, 2011 9:12 am
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

Posted: Tue Feb 08, 2011 3:18 pm
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,

Posted: Tue Feb 08, 2011 10:43 pm
by ray.wurlod

Code: Select all

if [ -z #filename# ] then
   echo "x1,x2,x3\n\np,q,r,s" > #filename#
fi