Total No. of "Records" in a File?

W. eWatson notvalid2 at
Sat Aug 23 19:53:24 CEST 2008

Nick Dumas wrote:
> Hash: SHA1
> want to know what is in a file before you open it? This could
> be done if you keep some external database documenting changes made to
> the file. But unless I misunderstand what you're saying, then it's not
> possible to know the contents of a file without opening and reading that
> file.
> W. eWatson wrote:
>> I have an ordinary text file with a CR at the end of a line, and two
>> numbers in each line. Is there some way to determine the number of lines
>> (records) in the file before I begin reading it?
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla -
> iEYEARECAAYFAkiwSZ4ACgkQLMI5fndAv9hXugCeJs5XBkLLne6ljqQggB/MoAVs
> SNIAoJxsU04cwcZMrH9QjElAbMD34RdK
> =RlmP
Maybe. I could see it if the file were truly in a record format. The # of 
records might be kept by the OS. It's conceivable that Python or the OS 
might see a file with a CR as "recordized". All unlikely though. Just checkin'.

How about in a slightly different case. Suppose I want to know the number of 
files in a folder? The OS and maybe some Python method might know that.

            Wayne Watson (Watson Adventures, Prop., Nevada City, CA)

              (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
               Obz Site:  39° 15' 7" N, 121° 2' 32" W, 2700 feet

                     Web Page: <>

More information about the Python-list mailing list