Hello
I am new to python programming. while trying it out i find that in my
code file io.read is not reading large files particularly over 1 gb. my
code is posted below. i am working on python 3.3 on windows with ntfs
partition and intel corei3 ram 3gb. the execution always stops saying
error with py.exe but idle editor and idle window remains open.
thank you
George
##function module generates md5 for given file data
import hashlib
import io
import os
def filemd5(file="g:\\filelargerthan1gb.iso"):
#print ("reached here")
#print ("File for processing %s",file)
try:
filelen=os.path.getsize(file)
except PermissionError:
print("Don't have permission for ",file,".\tTry running as
administrator")
return ''
if filelen>1073741824:
print ("file len greater than 1gb.\nNot hashing")
return ''
try:
f=open(file,'rb', buffering=0) #i have tried without
buffering also
except PermissionError:
print("Don't have permission for ",file,".\tTry running as
administrator")
return ''
try:
#print ("Readding")
fcontents=f.read()
#print ("Read successfully")
hashvalue=hashlib.md5(fcontents).hexdigest()
#print ("md5 successfully")
except:
hashvalue=''
print ("Error during reading md5")
f.close()
#print (hashvalue)
return hashvalue
filemd5()
---
This email is free from viruses and malware because avast! Antivirus protection
is active.
http://www.avast.com
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor