![](/img/trans.png)
[英]Parsing PubMed Central XML using Biopython Bio Entrez parse
[英]Issue with parsing publication data from PubMed with Entrez
我正在嘗試使用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()
正如其他評論和GitHub問題中所記錄的那樣,這個問題是由NCBI Entrez公用事業開發人員的故意改變引起的。 正如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()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.