From: Fortran_follower on
Hi,

Can anyone please tell me is there any chance/way to find out the size
of a file/no.of rows in a file....without actually opening it and
running a loop till the end of file...?

Thanking you.
Praveen.
From: Arjen Markus on
On 1 feb, 12:42, Fortran_follower <ezeepravee...(a)gmail.com> wrote:
> Hi,
>
> Can anyone please tell me is there any chance/way to find out the size
> of a file/no.of rows in a file....without actually opening it and
> running a loop till the end of file...?
>
> Thanking you.
> Praveen.

The size of a file is relatively easy: run a system command like "ls -
l" under
Linux or "dir" under Windows and analyse the output. Fortran-only
solutions
are compiler-dependent, though.

The second part of your question has the answer: that is impossible,
at least
in general. If your file is a direct-access file or a file with a
known structure
in general, then you can compute the number of rows/records from the
size.
Otherwise it is impossible, because modern file systems have no
concept of
what constitutes a row or record.

Regards,

Arjen
From: Gordon Sande on
On 2010-02-01 07:52:05 -0400, Arjen Markus <arjen.markus895(a)gmail.com> said:

> On 1 feb, 12:42, Fortran_follower <ezeepravee...(a)gmail.com> wrote:
>> Hi,
>>
>> Can anyone please tell me is there any chance/way to find out the size
>> of a file/no.of rows in a file....without actually opening it and
>> running a loop till the end of file...?
>>
>> Thanking you.
>> Praveen.
>
> The size of a file is relatively easy: run a system command like "ls -
> l" under
> Linux or "dir" under Windows and analyse the output. Fortran-only
> solutions
> are compiler-dependent, though.
>
> The second part of your question has the answer: that is impossible,
> at least
> in general. If your file is a direct-access file or a file with a
> known structure
> in general, then you can compute the number of rows/records from the
> size.
> Otherwise it is impossible, because


> modern file systems

Surely you mean "simple file systems" as unfortunately many current
popular computers (really operating systems) have file system with very
old historic roots. There is nothing modern about them except their
marketing. There are also several updated disk data structures but
that is not to be confused with their being modern as file systems.

> have no
> concept of
> what constitutes a row or record.
>
> Regards,
>
> Arjen


From: Arjen Markus on
On 1 feb, 14:40, Gordon Sande <g.sa...(a)worldnet.att.net> wrote:
>
> Surely you mean "simple file systems" as unfortunately many current
> popular computers (really operating systems) have file system with very
> old historic roots. There is nothing modern about them except their
> marketing. There are also several updated disk data structures but
> that is not to be confused with their being modern as file systems.
>

Ah, I have been trappen by for the marketing pitch. Yes, I mean:
the file systems you find on PCs and laptops running Linux or Windows
and, probably, their Apple/OSX counterparts.

(I have worked with an IBM minicomputer that did keep the file
structure
as part of its directory information, but that is a long time ago ...)

Regards,

Arjen
From: David Jones on
Fortran_follower wrote:
> Hi,
>
> Can anyone please tell me is there any chance/way to find out the size
> of a file/no.of rows in a file....without actually opening it and
> running a loop till the end of file...?
>
> Thanking you.
> Praveen.

There have been operating systems in which the default format for a file as actually stored was to include in a header information such as the file size (of two types, actual used and reserved size) and number of records. System-specific Fortran routines were available to access these. So the minute chance exists that you may be using a system such as this, one of which was a Honeywell of the 80's.

David Jones