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
Post a Comment