On Sun, May 18, 2014 at 8:38 PM, Vincent Davis <vinc...@vincentdavis.net> wrote:
> Well after posting, I think I figured it out.
> The key is to use StringIO to get a file handle on the string. The fact that
> it is binary just complicates it a little.
> with open('Tests/Affy/affy_v3_ex.CEL.bz2', 'rb') as handle:
>     cel_data = StringIO(decompress(handle.read()).decode('ascii'))

You can just use bz2.open:

>>> with bz2.open('test.txt.bz2', 'rt', encoding='ascii') as f:
...     print(f.read())

Reply via email to