Total No. of "Records" in a File?
Grzegorz Staniak
gstaniak at wp.pl
Sat Aug 23 14:38:30 EDT 2008
On 23.08.2008, W. eWatson <notvalid2 at sbcglobal.net> wroted:
> 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".
Isn't it much easier to use a database instead? That's what they're made for.
> 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.
Use "os" and "os.path". For a simple case the length of "os.listdir()" could
suffice, but then you might need to filter out sub-directories, or maybe
count files in them too using "os.walk()".
GS
--
Grzegorz Staniak <gstaniak _at_ wp [dot] pl>
More information about the Python-list
mailing list