Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to find size of file?

Reply
Thread Tools

How to find size of file?

 
 
Walter Huf
Guest
Posts: n/a
 
      03-05-2004
Hi, I'm the same one with the CGI download problem. This time, however, I
want to send the client the size of the file that will be downloaded. How
would I find the size of the file, so I can include that in the headers?

--Walter Huf--
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://hufman.cobalty.com


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Gerhard_H=E4ring?=
Guest
Posts: n/a
 
      03-05-2004
Walter Huf wrote:
> Hi, I'm the same one with the CGI download problem. This time, however, I
> want to send the client the size of the file that will be downloaded. How
> would I find the size of the file, so I can include that in the headers?


>>> import os
>>> os.stat("c:/tmp/x.html").st_size

567L

-- Gerhard
 
Reply With Quote
 
 
 
 
Yermat
Guest
Posts: n/a
 
      03-05-2004
Walter Huf a écrit :

> Hi, I'm the same one with the CGI download problem. This time, however, I
> want to send the client the size of the file that will be downloaded. How
> would I find the size of the file, so I can include that in the headers?
>
> --Walter Huf--
> (E-Mail Removed)
> http://hufman.cobalty.com
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 100,000 Newsgroups - 19 Different Servers! =-----


def sizeOf(f):
f.seek(0,2)
return f.tell()

 
Reply With Quote
 
Walter Huf
Guest
Posts: n/a
 
      03-05-2004
Yermat <(E-Mail Removed)1.nerim.net> wrote in
news:c2ai0g$1t4u$(E-Mail Removed):

> Walter Huf a écrit :


> def sizeOf(f):
> f.seek(0,2)
> return f.tell()
>


Thank you!


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
Irmen de Jong
Guest
Posts: n/a
 
      03-05-2004
Yermat wrote:


> def sizeOf(f):
> f.seek(0,2)
> return f.tell()
>


Hm. For better performance (and readability) try os.path.getsize(filename).....

--Irmen
 
Reply With Quote
 
=?ISO-8859-1?Q?I=F1igo?= Serna
Guest
Posts: n/a
 
      03-06-2004
Hi,

Other ways:

>> import os, stat
>> os.stat(filename)[stat.ST_SIZE]


Or better:

>> import os.path
>> os-path.getsize(filename)


Best regards,
Iñigo Serna

El vie, 05-03-2004 a las 22:13, Walter Huf escribió:
> Yermat <(E-Mail Removed)1.nerim.net> wrote in
> news:c2ai0g$1t4u$(E-Mail Removed):
>
> > Walter Huf a écrit :

>
> > def sizeOf(f):
> > f.seek(0,2)
> > return f.tell()
> >

>
> Thank you!
>
>
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----== Over 100,000 Newsgroups - 19 Different Servers! =-----



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQBAScPqfN63/+cBjZoRAg/kAJ422p6BEUwf+V8VxYiY3IBCDucp7wCgw3v0
HU7YGWzVPR8SoBpweVVYSTc=
=LJwG
-----END PGP SIGNATURE-----

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to exclude action of Find::Find::find in subdirectories withknown names? vdvorkin Perl Misc 0 02-10-2011 05:18 PM
Preferred Size, Minimum Size, Size Jason Cavett Java 5 05-25-2008 08:32 AM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
Find.find does not find orphaned links? Wybo Dekker Ruby 1 11-15-2005 02:50 PM



Advertisments