length of a dynamic 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
pmadhavi
Charter Member
Charter Member
Posts: 92
Joined: Fri Jan 27, 2006 2:54 pm

length of a dynamic file

Post by pmadhavi »

Hi

I need to find the length of a file dynamically. the file name starts with 'blankreport'. evryday a file gets created with the name 'BlankReport concatenated with the system date in it. I need to find the lenght of this dynamic file. I have a routine to get the lenght.
I am passing the file name as paramater.

I am passing the file name as 'BlankReport*.csv'

and it is not working. please let me know how to pass the filename without giving the date.

Thanks in Advance
Thanks,
Madhavi
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Can you post the routine so that we can try to see whats going on and possible try to pin point the culprit.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
meena
Participant
Posts: 430
Joined: Tue Sep 13, 2005 12:17 pm

Post by meena »

Hi Madhavi,
Post your routine.
pmadhavi
Charter Member
Charter Member
Posts: 92
Joined: Fri Jan 27, 2006 2:54 pm

Post by pmadhavi »

DSguru2B wrote:Can you post the routine so that we can try to see whats going on and possible try to pin point the culprit.
Please find the routine below to calculate the lenght of the file.

INCLUDE DSINCLUDE JOBCONTROL.H

Openseq Arg1 To fp
then print 'Welcome'
Readseq A from fp
then Print 'Welcome'
if len(A) > 807
then Ans=1
else Ans=0
closeseq fp

NOTE: where 807 is the length of the column headings. Mroethan that number means there is data in the file and mail will be trigegred.
Thanks,
Madhavi
pmadhavi
Charter Member
Charter Member
Posts: 92
Joined: Fri Jan 27, 2006 2:54 pm

Post by pmadhavi »

pmadhavi wrote:
DSguru2B wrote:Can you post the routine so that we can try to see whats going on and possible try to pin point the culprit.
I have a solution to the file name problem. ie before finding the length of the file, as it is a dynamic file, we will copy it to another file and find the length of that file. the second file name is constant. Everytime the dynamic file gets created, we copy it to another file and then find the length. This way it is working fine.

But the new problem I am facing is even the file is empty i.e when the file contains only the column headings, there is a special character in the file down the first col heading increasing the file length and thus triggering a mail.

Please let me know how to delete the special character.

Thanks in Advance.
Thanks,
Madhavi
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Does that character exist no matter how many times you execute it?
What i am trying to say is, if that character takes up 1 byte then instead of checking for 807, you should check for 808. But thorough testing is needed.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

pmadhavi wrote: NOTE: where 807 is the length of the column headings. Mroethan that number means there is data in the file and mail will be trigegred.
I am afraid you are wrong. readseq will only return the first line which will be column names and no matter how large the file is, that size will remain constant, unless you change the column names, offcourse.
You need to use the STATUS() function along with OPENSEQ to get the file size.
You need something like this,

Code: Select all

      INCLUDE DSINCLUDE JOBCONTROL.H

      Openseq Arg1 To fp
         then print 'Welcome' 
      STATUS fileSize FROM fp
         then print fileSize
      Ans=fileSize<6,1,1>
      Closeseq fp

Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
pmadhavi
Charter Member
Charter Member
Posts: 92
Joined: Fri Jan 27, 2006 2:54 pm

Post by pmadhavi »

I am really confused.
When there is no data, the routine you suggested gives 896.
But if I count the length of the column headings it is coming as 807. I get 807 even if I manually delete the data row keeping the headings alone.

I dont know what is that extra which counts when the file is created without any data in it.

When I open the csv file in a notepad I dont see extra characters except '' at the end of last column heading.

please tell me why the diffreence of length is coming

Please help me out.
Thanks,
Madhavi
pmadhavi
Charter Member
Charter Member
Posts: 92
Joined: Fri Jan 27, 2006 2:54 pm

Post by pmadhavi »

Test Output:

TEST #1
*******

Arg1 = \\appbca\data_files\XYZ\Copyfile.csv

Test completed.

Welcome
0
0
0
896
33206
896
1
-2
0
2013522242
1980505895
3
43019
14178
43019
14178
39072
14178

\\appbca\data_files\XYZ\Copyfile.csv









PROD\ticap

Result = 896


Please tell me regd the numbers that got generated when I ran the routine from DS Manager
Thanks,
Madhavi
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

If it gave 896 then thats the size of just the column names. 896 bytes of data.
Keep in mind that its not just column names, but also double quotes and delimiters.
Add data to the file and then test my routine. Then delete data and only keep the column names and then test my routine. It should work.
Even if you get rid of the special character, your code will always check for the first line, regardless if there is more data or not.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
pmadhavi
Charter Member
Charter Member
Posts: 92
Joined: Fri Jan 27, 2006 2:54 pm

Post by pmadhavi »

Hi DSGuru

Thanks for the suggestion. Your routine is working fine.
Thanks,
Madhavi
Post Reply