python - get file size of the file from the file object -


i need know size of file based on file object

import csv import os open("test.csv", "rb") infile:     reader = csv.reader(infile)     print reader     filesize(reader) def filesize(reader):     os.getsize(reader) #and need work reader more details.so must need pass reader or file object 

when run got output

<_csv.reader object @ 0x7f5644584980> 

from file object how size of file?

and checked site these not csv attribute size of open file object

edit: when use 2 inbuilt function got errors

attributeerror: '_csv.reader' object has no attribute 'seek' attributeerror: '_csv.reader' object has no attribute 'tell'

what's wrong os.path.getsize?

with code:

import os import csv open("test.csv", "rb") infile:    reader = csv.reader(infile)    print os.path.getsize(infile.name) 

the size in bytes.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -