我试图使用Entrez将发布数据导入数据库。搜索部分工作正常,但当我试图解析时:
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()..。我得到以下错误:
文件"/venv/lib/python2.7/site-packages/Bio/Entrez/Parser.py",第296行,在解析ValueError(“XML文件不代表列表。请使用Entrez.read而不是Entrez.parse") ValueError: XML文件不代表列表。请使用Entrez.read而不是Entrez.parse
直到几天前,这段代码才开始工作。有什么想法吗这里可能出了什么问题?
此外,查看源代码(http://biopython.org/DIST/docs/api/Bio.Entrez-pysrc.html)并尝试遵循列出的示例,也会出现相同的错误:
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()发布于 2017-02-03 02:04:43
正如其他评论和GitHub问题中所记录的那样,这个问题是由NCBI实用程序开发人员故意做出的更改造成的。正如Jhird在这个问题中所描述的,您可以将代码更改为:
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()https://stackoverflow.com/questions/41286823
复制相似问题