Hi, I am currently working on a class project that requires me to pull data from the NCBI website using biopython and writing it to a CSV file which I then analyze in R. I got all the data I need, but I'm not completely sure how to write it into a CSV file since we never covered it in class. Here is my code so far:
from Bio import Entrez, Medline Entrez.email = "email.here" handle = Entrez.esearch(db="pubmed", # database to search term="Chan CS[Author] AND 2000:2017[Date - Publication]", # search term retmax=200 # Maximum number of results to return ) record = Entrez.read(handle) handle.close() pmid_list = record["IdList"] print(pmid_list)
from Bio import Medline handle = Entrez.efetch(db="pubmed", id=pmid_list, rettype="medline", retmode="text") records = Medline.parse(handle) journal_dict =  datep_dict =  place_dict =  for record in records: # retrieve a journal name title = record['JT'] journal_dict.append(title) date = record['DP'] datep_dict.append(date) place = record['PL'] place_dict.append(place) # Close the efetch handle handle.close() # print final journal name and coun for title in journal_dict: print(title) for date in datep_dict: print(date) for place in place_dict: print(place)
What I would like my xcel sheet to look like would be
[ID, Journal Title, Publication Date, Place of Publication] [123, Title1, Date1, Place1] [124, Title2, Date2, Place2]
etc. Any help would be greatly appreciated!