Computing.Net > Forums > Programming > Determine length of file in Python

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Determine length of file in Python

Reply to Message Icon

Name: Birdman
Date: December 29, 2004 at 10:21:37 Pacific
OS: Mepis (2.6.7)
CPU/Ram: 80x86
Comment:

I can't figure out how to get the length of a file in Python. The files I'm dealing with are relatively small, so I could read() the whole thing into a buffer then get len(buffer), but there must be an easier way. Google isn't helping, so I figured I'd ask here.

Any help is appreciated!



Sponsored Link
Ads by Google

Response Number 1
Name: Wolfbone
Date: December 29, 2004 at 12:44:50 Pacific
Reply:

What's wrong with stat()? And what's wrong with Mepis - doesn't it provide the Python docs? If not, they are all available online at python.org, along with other resources.


0

Response Number 2
Name: Birdman
Date: December 29, 2004 at 15:46:36 Pacific
Reply:

stat() is great!
Nothing is wrong with MEPIS!

The Python docs make no reference to stat() under the file object IO sections... rather it is found (I went back and checked) under Chapter 6.1 (OS), section 4, "Files and Directories". When looking for information on reading and writing files, I went for the built in file object documentation, which makes no mention of anything in the os module. Seeing as the sections are quite interrelated, a link or two across would have been helpful!

Thanks for the help!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Determine length of file in Python

Count number of files in zip archive www.computing.net/answers/programming/count-number-of-files-in-zip-archive/20254.html

Count number of files in directory www.computing.net/answers/programming/count-number-of-files-in-directory-/15868.html

count no of files in a directory www.computing.net/answers/programming/count-no-of-files-in-a-directory/18316.html