On 2014-05-18 19:53, Vincent Davis wrote:
> I have a file compressed with bz2 and a function that expects a
> file handle. When I decompress the bz2 file I get a string (binary)
> not a file handle.
> from bz2 import decompress,
> with open('Tests/Affy/affy_v3_ex.CEL.bz2', 'rb') as handle:
> cel_data = decompress(handle.read())
When I try (without the Bio.Affy which isn't part of the stdlib), I
get correct bytes from this:
tim@bigbox:~$ echo hello world > test.txt
tim@bigbox:~$ bzip2 -9 test.txt
Python 3.2.3 (default, Feb 20 2013, 14:44:27)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from bz2 import decompress
>>> with open('test.txt.bz2', 'rb') as f:
... data = decompress(f.read())
> c = CelFile.read(cel_data)
So either you have bad data in the file to begin with, or your
CelFile.read() function has a bug in it.