[Biopython] [Entrez] bytes objects has no attribute 'read'
Peter Cock
p.j.a.cock at googlemail.com
Sat Dec 19 23:11:07 UTC 2015
On Sat, Dec 19, 2015 at 12:55 PM, <c.buhtz at posteo.jp> wrote:
> Don't know what is going on here.
> The used zip file has two xml-files with eFetch-records in it.
>
>>>> import Bio.Entrez, zipfile;
>>>> z = zipfile.ZipFile('test.zip')
>>>> h = z.read(z.namelist()[0])
Calling z.read(filename) would return the contents of the file in
the zip file as a bytes string.
You need a handle-like object to give to the Biopython parser,
which must support the read method, so:
h = z.open(z.namelist()[0])
for i in Bio.Entrez.parse(h):
print(i)
Is that better?
Peter
More information about the Biopython
mailing list