comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: handling zero size file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: handling zero size file [message #52559] Mon, 12 February 2007 14:27 Go to next message
Kenneth Bowman is currently offline  Kenneth Bowman
Messages: 86
Registered: November 2006
Member
In article <eqqo6t$7u0$1@news.nems.noaa.gov>,
Spam Bob <spambob@bikinibottom.net> wrote:

> I have an idl program that I call from perl. I send the idl program two
> files (file1 and file2).
>
> PRO mentor_nf, file1, file2, loc
>
> If both files are nonzero size it runs fine plotting both (this is a two
> panel plotting program). If I'm missing some data and either file1 or
> file2 is zero size, the program bombs. I would like it to go ahead and
> plot the nonzero sized file and just leave the other panel blank.
>
> Here is where the program fails:
> DATA1 = READ_ASCII(file1, TEMPLATE=PLOTTEMPLATE)
>
> and this is the error:
> % READ_ASCII: File "/data/file1_20060322.dat" is not a valid ASCII file.
>
> I tried the MISSING_VALUE keyword but that didn't change anything.

Use FILE_INFO to check the file size before opening it.

Ken Bowman
Re: handling zero size file [message #52560 is a reply to message #52559] Mon, 12 February 2007 15:09 Go to previous message
Spam Bob is currently offline  Spam Bob
Messages: 2
Registered: February 2007
Junior Member
hradilv wrote:
> On Feb 12, 4:03 pm, Spam Bob <spam...@bikinibottom.net> wrote:
>> I have an idl program that I call from perl. I send the idl program two
>> files (file1 and file2).
>>
>> PRO mentor_nf, file1, file2, loc
>>
>> If both files are nonzero size it runs fine plotting both (this is a two
>> panel plotting program). If I'm missing some data and either file1 or
>> file2 is zero size, the program bombs. I would like it to go ahead and
>> plot the nonzero sized file and just leave the other panel blank.
>>
>> Here is where the program fails:
>> DATA1 = READ_ASCII(file1, TEMPLATE=PLOTTEMPLATE)
>>
>> and this is the error:
>> % READ_ASCII: File "/data/file1_20060322.dat" is not a valid ASCII file.
>>
>> I tried the MISSING_VALUE keyword but that didn't change anything.
>
> Try FILE_INFO()

Thanks for the reply. I looked up FILE_INFO but I think you meant
FILE_TEST. I actually came up with a workaround after I posted my
question (put some dummy data in "file" if it is empty), but I can come
up with a better solution with FILE_TEST. I'd like the empty panel to
display something like "No data for this day" if the file is zero size.
Re: handling zero size file [message #52562 is a reply to message #52559] Mon, 12 February 2007 14:33 Go to previous message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Feb 12, 4:03 pm, Spam Bob <spam...@bikinibottom.net> wrote:
> I have an idl program that I call from perl. I send the idl program two
> files (file1 and file2).
>
> PRO mentor_nf, file1, file2, loc
>
> If both files are nonzero size it runs fine plotting both (this is a two
> panel plotting program). If I'm missing some data and either file1 or
> file2 is zero size, the program bombs. I would like it to go ahead and
> plot the nonzero sized file and just leave the other panel blank.
>
> Here is where the program fails:
> DATA1 = READ_ASCII(file1, TEMPLATE=PLOTTEMPLATE)
>
> and this is the error:
> % READ_ASCII: File "/data/file1_20060322.dat" is not a valid ASCII file.
>
> I tried the MISSING_VALUE keyword but that didn't change anything.

Try FILE_INFO()
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: attn: courtnay - very well designed nntp access - tib oh - (1/1)
Next Topic: quickly totaling sections of an array

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:12:44 PDT 2025

Total time taken to generate the page: 0.00782 seconds