Truncate file header in Python
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).
+3
sweet_sugar
source
to share
1 answer
Use the method 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.
+3
dobkind
source
to share