0

Hi,
I want to know how to read the binary file from 10th byte to 90th byte in a file size of 100 bytes and need to write the read data into new binary file.
please help me in doing this.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by hisan
0
with open('binfile.dat', 'rb') as bf:
      bf.seek(10)
      open('out.dat', 'wb').write(bf.read(80))

Something like this. This is untested as I am not with computer now. Maybe you must seek(9) and/or read(81).

Edited by pyTony: n/a

0

You should be able to read the 100 bytes, split and write. The following code uses 25 bytes and splits from 10 through 20 (11 bytes) for simplicity.

alpha = "abcdefghijklmnopqrstuvwxy"
print alpha
print alpha[9:20]

Edited by woooee: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.