danielecook
3/29/2016 - 6:10 PM

Fetch publications from pubmed and convert to YAML

Fetch publications from pubmed and convert to YAML

"""
Daniel E. Cook 2013 
(danielecook.com)

"""

from metapub import PubMedFetcher
import yaml

q = PubMedFetcher()


def fetch_pub(pmid):
    pub = q.article_by_pmid(pmid)
    return pub.to_dict()


pub_list = open("../pub/publications_list.txt", 'r').read().splitlines()[1:]
with open("../_data/pubs_data2.yaml", 'w') as f:
    f.write(yaml.safe_dump([fetch_pub(x) for x in pub_list]))