Issue with parsing publication data from PubMed with Entrez

I am trying to use Entrez to import publication data into a database. Part of the search works fine, but when I try to parse:

from Bio import Entrez def create_publication(pmid): handle = Entrez.efetch("pubmed", id=pmid, retmode="xml") records = Entrez.parse(handle) item_data = records.next() handle.close() 

... I get the following error:

File "/venv/lib/python2.7/site-packages/Bio/Entrez/Parser.py", line 296, in a parse raise ValueError ("The XML file does not represent a list. Use Entrez.read instead of Entrez.parse") ValueError: The XML file is not a list. Use Entrez.read instead of Entrez.parse

This code worked until a few days ago. Any ideas what might be wrong here?

Also, looking at the source code ( http://biopython.org/DIST/docs/api/Bio.Entrez-pysrc.html ) and trying to follow the given example, the same error appears:

 from Bio import Entrez Entrez.email = " Your.Name.Here@example.org " handle = Entrez.efetch("pubmed", id="19304878,14630660", retmode="xml") records = Entrez.parse(handle) for record in records: print(record['MedlineCitation']['Article']['ArticleTitle']) handle.close() 
+5
source share
1 answer

The issue described in other comments and the GitHub Issue is caused by a deliberate change made by the developers of the NCBI Entrez Utilities. As described in this release of Jhird, you can change your code to the following:

 from Bio import Entrez Entrez.email = " Your.Name.Here@example.org " handle = Entrez.efetch("pubmed", id="19304878,14630660", retmode="xml") records = Entrez.read(handle) # Difference here records = records['PubmedArticle'] # New line here for record in records: print(record['MedlineCitation']['Article']['ArticleTitle']) handle.close() 
+2
source

Source: https://habr.com/ru/post/1261729/


All Articles