Not able to prevent generation of empty CSV 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
kasgang
Premium Member
Premium Member
Posts: 9
Joined: Wed Oct 18, 2006 8:18 am

Not able to prevent generation of empty CSV file

Post by kasgang »

Hi Gurus

I am generating a CSV file from within a job with sequential file stage.However , whenever there is no data at the source side , it is generating a blank CSV file. Is there any way I can prevent this or any workaround .
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Prevent? No. If it really bothers you, you can build an after-job subroutine to detect the empty file and delete it if you like.
-craig

"You can never have too many knives" -- Logan Nine Fingers
gateleys
Premium Member
Premium Member
Posts: 992
Joined: Mon Aug 08, 2005 5:08 pm
Location: USA

Re: Not able to prevent generation of empty CSV file

Post by gateleys »

kasgang wrote: I am generating a CSV file from within a job with sequential file stage.However , whenever there is no data at the source side , it is generating a blank CSV file.
Isn't it supposed to?? :roll:
kasgang wrote: Is there any way I can prevent this or any workaround .
Why would you want to prevent this?
gateleys
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
By definition an empty fie should contain nothing if it is really empty :!:
This is done as part of the overwrite operation on the previos file.

You can try to delete any existing file, then only run the job if there are rows to process.
Or you can delete the file after verifying no rows were written to it.
IHTH,
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

roy wrote:By definition an empty fie should contain nothing if it is really empty :!:
Or it could contain a single header record. That's why, IMHO, you should check the LinkRowCount and not the file size as that will 'always' work for you.
-craig

"You can never have too many knives" -- Logan Nine Fingers
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

OK I ment DATA wise Craig, probably that exclamation mark was uncalled for :wink:
Craig if you were refering to a file header record that contains some general and or validation data like the number of rows that the file should contain then that is also data.

Obviously the way to determine number of rows is subject to the process logic and should reflect a proper method to reflect existance of or lack of rows :)
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
kasgang
Premium Member
Premium Member
Posts: 9
Joined: Wed Oct 18, 2006 8:18 am

Post by kasgang »

Hi Gurus

Thanks for the inputs. By empty files I meant , file with header rows only . The way I am doing it now , is checking the LinkRowCount and writing to another file the filenames with LinkRowCount=0.
Then I am deleting the empty CSV files referring to this file.

Just wanted to know if there is anythig better that way to do the same.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

I guess the only 'better' way would be to stop worrying about it and just leave them alone. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
parag.s.27
Participant
Posts: 221
Joined: Fri Feb 17, 2006 3:38 am
Location: India
Contact:

use folder stage

Post by parag.s.27 »

Make use of Folder stage as the target stage instead of the sequential file stage and your requirement will be achieved easily. we have done the same things successfully.
Thanks & Regards
Parag Saundattikar
Certified for Infosphere DataStage v8.0
Post Reply