hi,
I wish to read files, but also to be able to handle empty files since
so far the prog gives me a floating exception error and stops whenever
it encounters such a file.
so, I basically wish to identify an empty file, state it is empty, and
go on to the next file, the lot without crashing.
any ideas ?
many thanks!
G.
|
|
0
|
|
|
|
Reply
|
tperzo (4)
|
12/31/2003 11:33:03 AM |
|
On Wed, 31 Dec 2003 11:33:03 +0000, news <tperzo@wanadoo.fr>
wrote in <bsu8og$52s$1@news-reader4.wanadoo.fr>:
> hi,
> I wish to read files, but also to be able to handle empty files since
> so far the prog gives me a floating exception error and stops whenever
> it encounters such a file.
> so, I basically wish to identify an empty file, state it is empty, and
> go on to the next file, the lot without crashing.
What statement are you using to read the files? Are you aware of
the END and ERR keywords in the READ statement?
--
Ivan Reid, Electronic & Computer Engineering, ___ CMS Collaboration,
Brunel University. Ivan.Reid@brunel.ac.uk Room 40-1-B12, CERN
KotPT -- "for stupidity above and beyond the call of duty".
|
|
0
|
|
|
|
Reply
|
Ivan.Reid (496)
|
12/31/2003 12:54:44 PM
|
|
"news" <tperzo@wanadoo.fr> wrote in message
news:bsu8og$52s$1@news-reader4.wanadoo.fr...
> hi,
> I wish to read files, but also to be able to handle empty files
since
> so far the prog gives me a floating exception error and stops
whenever
> it encounters such a file.
> so, I basically wish to identify an empty file, state it is empty,
and
> go on to the next file, the lot without crashing.
>
> any ideas ?
>
> many thanks!
>
> G.
>
f2003
inquire (file='anyfile',size=isize)
if (isize == 0) then
cvf
open (1,file='anyfile',position='append')
if (ftell(1) == 0) then
|
|
0
|
|
|
|
Reply
|
dave_frank (2243)
|
12/31/2003 12:56:25 PM
|
|
Dr Ivan D. Reid wrote:
> On Wed, 31 Dec 2003 11:33:03 +0000, news <tperzo@wanadoo.fr>
> wrote in <bsu8og$52s$1@news-reader4.wanadoo.fr>:
>> hi,
>> I wish to read files, but also to be able to handle empty files since
>> so far the prog gives me a floating exception error and stops whenever
>> it encounters such a file.
>> so, I basically wish to identify an empty file, state it is empty, and
>> go on to the next file, the lot without crashing.
>
> What statement are you using to read the files? Are you aware of
> the END and ERR keywords in the READ statement?
>
open (unit=30,file="masterfile.dat")
read (30,*,END=805) filename
here the name contained in filename is in masterfile.dat
yes I have heard of the ERR command, but it does not seem to be recognized
by f77 under linux. (mandrake 9.1)
|
|
0
|
|
|
|
Reply
|
igthibau (46)
|
1/2/2004 11:42:50 PM
|
|
igthibau <igthibau@wanadoo.fr> writes:
> yes I have heard of the ERR command, but it does not seem to be recognized
> by f77 under linux. (mandrake 9.1)
That seems unlikely. It is standard f77, and I'm quite sure that I have
used it with g77 (which is what you'd presumably have as the f77 in
that distribution). However, do note
1. It isn't a command (or statement either). It is just a keyword,
like the end=. I assume you are probably using the wrong
terminology, but occasionally it is worth checking assumptions
like that, because sometimes the assumptions are wrong.
2. More likely to be your problem - hitting and end of file does not
count as an error.
I really have trouble believing that the compiler doesn't recognize
a syntactically correct err=. If it compiles without error, then
the compiler recognized it. If it gives a compilation error message,
then I'd like to see the code and message; my natural assumption
would be that there was a syntax error...perhaps you spelled it error=
instead of err=, or perhaps you gave it a variable name (like
iostat= needs) instead of a statement number.
--
Richard Maine
email: my last name at domain
domain: sumertriangle dot net
|
|
0
|
|
|
|
Reply
|
nospam47 (9742)
|
1/3/2004 3:08:08 AM
|
|
On Fri, 02 Jan 2004 23:42:50 +0000, igthibau <igthibau@wanadoo.fr>
wrote in <bt4svo$elr$1@news-reader2.wanadoo.fr>:
> Dr Ivan D. Reid wrote:
>> What statement are you using to read the files? Are you aware of
>> the END and ERR keywords in the READ statement?
> open (unit=30,file="masterfile.dat")
> read (30,*,END=805) filename
^
|
> here the name contained in filename is in masterfile.dat
> yes I have heard of the ERR command, but it does not seem to be recognized
> by f77 under linux. (mandrake 9.1)
Many of the problems seen here result from using wildcarded I/O
statements. This could be one of them. Whereas formatted read statements
will read the exact number of records specified, wildcarded reads will
keep trying to read new records until the input-variable list is satisfied.
This may not give the behaviour that is required (especially for a
character variable, as appears to be the case here).
IF YOU CARE ABOUT THE BEHAVIOUR, ALWAYS USE EXPLICIT FORMAT!
--
Ivan Reid, Electronic & Computer Engineering, ___ CMS Collaboration,
Brunel University. Ivan.Reid@brunel.ac.uk Room 40-1-B12, CERN
KotPT -- "for stupidity above and beyond the call of duty".
|
|
0
|
|
|
|
Reply
|
Ivan.Reid (496)
|
1/3/2004 8:55:32 AM
|
|
|
5 Replies
56 Views
(page loaded in 0.119 seconds)
Similiar Articles: WRITE fails when record is greater than 255 chars - comp.os.vms ...Hello All I am reading from a RELATIVE file from DCL and writing to ... is too long - shorten And the output file is empty. ... suggest that DCL would not be able to handle ... Reading ASCII text file with variable number of columns - comp ...... are by far the hardest to deal with w ... missing values or >> simply empty fields, I'd strongly recommend building the file ... one by one) from a text file ... Reading ASCII ... How can i check if my file handle has been stale - comp.lang.tcl ...Hi If my file handle has been stale How can i check it in Tcl. ... ... The TCL eof manpage reads: Returns 1 if an end of file condition occurred during the most ... Data with "," and field sepeator is ",", How to handle this - comp ...HI All How to handle Data with "," and field sepeator is "," ? Data file Case 1 field number two without ... There's two more empty dummy fields in this case, and you ... How to handle if nfs hangs - comp.unix.programmerHi, I have an application which reads from the nfs mounted directory. My program opens the file and read all ... NFS file handle vickey@vickey-laptop:/$ rm -r vada rm ... How to avoid Out of Memory Errors when dealing with a large XML ...> > > I'm reading a large (57 MB) XML file Using XML::XPath::XMLParser() > > > I keep getting this ... comp.cad.solidworks how to overcome "java ... jvm - How to deal with ... How to send "mail", with no body, from within a UNIX script - comp ...I know the code below works, but I do not want to employ the empty file, "admtest ... The only thing I can think of is writing the output to a named pipe, and reading the ... Reading a directory and selecting only desired filenames - comp ...The following code reads a directory and places all the filenames into a SAS dataset. ... handle=dopen('_dir_'); if handle > 0 ... GAWK: A fix for "missing file is a fatal error" - comp.lang.awk ...... workaround using getline IF you need to deal with ... It does that today if the input file is empty and *I ... FNR=1) fatal: cannot open file `f2' for reading (No such file ... how to read ndpi image (tiff format) - comp.soft-sys.matlab ...... ve looked at seems to exceed the limit of what libtiff can handle ... comp.soft-sys.matlab TIF Image File Format TIFF - Tag Image File Format (.TIF file extension ... reading ... MAINFRAME FORUM: Reading Empty vsam file failed with status code 90Hi, In my cobol module, our VSAM file empty. In order to handle empty VSAM file, we used OPTIONAL in SELECT statement. Since it has Alternate index file is present ... How to find whether a Flat file is empty or not without Reading a ...How to find whether a Flat file is empty or not without Reading a file in ... It is always better to check the file code after every open statement and handle the empty file ... 7/22/2012 2:41:27 PM
|