[Biopython] [Entrez] use the handle twice
Michiel de Hoon
mjldehoon at yahoo.com
Mon Dec 21 02:19:11 UTC 2015
You could use StringIO and save the output from handle.read in memory. Then you can use the data in StringIO twice; once to parse the XML, and once to save it to disk.The easiest solution of course is to simply parse the XML file you have saved. I don't see why that doesn't count as a solution.-Michiel
On Saturday, December 19, 2015 7:09 PM, "c.buhtz at posteo.jp" <c.buhtz at posteo.jp> wrote:
I want to use the handle returned by Entrez.efetch() twice.
First time, write the xml to a file
f.write(handle._handle.read())
But I want to know how much records are in there.
records = Entrez.read(handle)
print(records['Count'])
This doesn't work here because the handle is "empty" after the first
read()-call.
Open an read the xml-file would be a resource wasting workaround and not
a solution.
--
GnuPGP-Key ID 0751A8EC
_______________________________________________
Biopython mailing list - Biopython at mailman.open-bio.org
http://mailman.open-bio.org/mailman/listinfo/biopython
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython/attachments/20151221/86657805/attachment.html>
More information about the Biopython
mailing list