Question about reading a big binary file and write it into several text (ascii) files

Albert Tu sjtu.0992 at gmail.com
Mon Jan 24 15:44:32 EST 2005


Hi,

I am learning and pretty new to Python and I hope your guys can give me
a quick start.

I have an about 1G-byte binary file from a flat panel x-ray detector; I
know at the beggining there is a 128-byte header and the rest of the
file is integers in 2-byte format.

What I want to do is to save the binary data into several smaller files
in integer format and each smaller file has the size of 2*1024*768
bytes.

I know I can do something like
>>>f=open("xray.seq", 'rb')
>>>header=f.read(128)
>>>file1=f.read(2*1024*768)
>>>file2=f.read(2*1024*768)
>>>......
>>>f.close()

Bur I don't them how to save files in integer format (converting from
binary to ascii files) and how to do this in an elegant and snappy way.


Please reply when you guyes can get a chance.
Thanks,
Warm regards,
Albert




More information about the Python-list mailing list