Binary file output using python

Michael Hoffman cam.ac.uk at mh391.invalid
Tue Apr 17 16:20:14 EDT 2007


Michael Hoffman wrote:
> Chi Yin Cheung wrote:
>> Hi,
>> Is there a way in python to output binary files? I need to python to 
>> write out a stream of 5 million floating point numbers, separated by 
>> some separator, but it seems that all python supports natively is 
>> string information output, which is extremely space inefficient.
> 
> I recommend using PyTables for this sort of thing. It also allows you to 
> choose from several compression algorithms. I'm using it to store files 
> with 22000 x (2000, 12) datasets, or 528 million Float64s.

Addendum: it should also deal with endianness issues I wouldn't want to 
handle myself, so your code will also be portable.
-- 
Michael Hoffman



More information about the Python-list mailing list