Example #1
0
def pubmed_ids_to_d(pmids):
    print "fetching articles..."
    articles = pubmedpy.batch_fetch(pmids)
    print "ok."

    articles = [article for article in articles if len(article) >= 3]

    pmids_d = {}
    none_to_str = lambda x: x if x is not None else ""

    for article in articles:
        title_text = article.get("TI")
        ab_text = article.get("AB")
        authors = none_to_str(article.get("AU"))
        journal = none_to_str(article.get("JT"))
        keywords = none_to_str(article.get("MH"))
        pmid = int(article["PMID"])
        pmids_d[pmid] = {
            "title": title_text,
            "abstract": ab_text,
            "journal": journal,
            "keywords": keywords,
            "pmid": pmid,
            "authors": authors,
        }
    return pmids_d
Example #2
0
def pubmed_ids_to_db(pmids, db_path):
    print "fetching articles..."
    articles = pubmedpy.batch_fetch(pmids)
    print "ok."

    pmids_to_abs = {}
    none_to_str = lambda x: x if x is not None else ""
    for article in articles:
        title_text = article.get("TI")
        ab_text = article.get("AB")
        authors = none_to_str(article.get("AU"))
        journal = none_to_str(article.get("JT"))
        keywords = none_to_str(article.get("MH"))
        pmid = int(article["PMID"])
        pmids_to_abs[pmid] = {"title":title_text, "abstract":ab_text, "journal":journal,\
                                             "keywords":keywords, "pmid":pmid, "authors":authors}
    d_to_sql(pmids_to_abs, db_path, "chris")
Example #3
0
def pubmed_ids_to_db(pmids, db_path):
    print "fetching articles..."
    articles = pubmedpy.batch_fetch(pmids)
    print "ok."

    pmids_to_abs = {}
    none_to_str = lambda x: x if x is not None else ""
    for article in articles:
        title_text = article.get("TI")
        ab_text = article.get("AB")    
        authors = none_to_str(article.get("AU"))
        journal = none_to_str(article.get("JT"))
        keywords = none_to_str(article.get("MH"))
        pmid = int(article["PMID"])
        pmids_to_abs[pmid] = {"title":title_text, "abstract":ab_text, "journal":journal,\
                                             "keywords":keywords, "pmid":pmid, "authors":authors}
    d_to_sql(pmids_to_abs, db_path, "chris")    
Example #4
0
def pubmed_ids_to_d(pmids):
    print "fetching articles..."
    articles = pubmedpy.batch_fetch(pmids)
    print "ok."

    articles = [article for article in articles if len(article) >= 3]

    pmids_d = {}
    none_to_str = lambda x: x if x is not None else ""

    for article in articles:
        title_text = article.get("TI")
        ab_text = article.get("AB")
        authors = none_to_str(article.get("AU"))
        journal = none_to_str(article.get("JT"))
        keywords = none_to_str(article.get("MH"))
        pmid = int(article["PMID"])
        pmids_d[pmid] = {"title":title_text, "abstract":ab_text, "journal":journal,\
                                             "keywords":keywords, "pmid":pmid, "authors":authors}
    return pmids_d