How to trim x bytes of head file? I have a journal that has 5 GB and I want to shrink the first 3 GB (delete old information).
Use the method seek :
seek
fname = 'bigfile.log' fid = open(fname, "rb") fid.seek(3 * (2 ** 30) , 0) # go to the ~(3*10^9)th Byte, with respect to the start Buffer = fid.read(2 * (2 ** 30))
Click here for more information.