[Tutor] Splitting a file
taserian at gmail.com
Sun Dec 17 13:52:54 CET 2006
I'm attempting to split a binary file into 5 component files, as a
"challenge". I thought that the following would work:
f = open('/home/taser/Desktop/inputfile.bin')
f1 = 
f2 = 
f3 = 
f4 = 
f5 = 
bytes = list(f.read(5))
ff1 = open('/home/taser/Desktop/ff1.file','w')
I've only dealt with one of the lists, since I want to test it before
doing the rest.
I'm unsure if I'm going about this correctly, since I'm manipulating
binary data as if it were a text file.
Also, I'm told that I should be able to have Python itself determine the
type of file it is, since the file contains a "magic number". However, I
haven't had any luck in my searches for how to do that in Python.
Any help would be appreciated.
More information about the Tutor