I have a file ( size : 20 mb | binary file ) that needs to be parsed every 820 bytes and that very content of 820 saved into a new file with the name of the file being the string(ASCII) between the 2byte and the 16byte mark.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
^ THE FILENAME COMES FROM HERE ^
Ok now that the challenge is explained ( i hope ) what i do have for now is this :
Hmmm i don't know how to iterate every time i read the buffer and the f.read reaches 820 bytes and save it to a new file every 820bytes then the next 820bytes and continue to the end of the file .
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
^ THE FILENAME COMES FROM HERE ^
Ok now that the challenge is explained ( i hope ) what i do have for now is this :
Code:
#!/usr/bin/python
with open("file", "rb") as f:
byte = f.read()
if byte > 820:
print "Reach the 1 record mark on the File you have defined "
Hmmm i don't know how to iterate every time i read the buffer and the f.read reaches 820 bytes and save it to a new file every 820bytes then the next 820bytes and continue to the end of the file .
Comment