Nov-01-2022, 12:00 PM
Hi team
I am creating a checksum. using below code.
Code is working, My csv is 15gb.
hence I am reading data in chunk.
data = f.read(10240)
is this correct or any better solution available.
thanks for help !
I am creating a checksum. using below code.
Code is working, My csv is 15gb.
hence I am reading data in chunk.
data = f.read(10240)
is this correct or any better solution available.
thanks for help !
import hashlib import os import time import ReadTime def chksum(fpath, fname): start = time.time() h = hashlib.sha512() fullpath = os.path.join(fpath, fname) with open(fullpath, 'rb') as f: while True: data = f.read(10240) if not data: break h.update(data) chksum = h.hexdigest() fname = fname.replace('.csv', "") chksumpath = os.path.join(fpath, 'f{fname}_chksum.csv') with open(chksumpath, 'w') as data: data.write(chksum) tmp = time.time()-start print("time taken to create checksum", ReadTime.timetaken(tmp))