I am working on a project that requires me to search through pubmed
using inputs from an Excel
spreadsheet and print counts of the results. I have been using xlrd
and entrez
to do this job. Here is what I have tried.
I need to search through
pubmed
using the name of the author, his/her medical school, a range of years, and his/her mentor's name, which are all in anExcel
spreadsheet. I have usedxlrd
to turn each column with the required information into lists of strings.from xlrd import open_workbook book = xlrd.open_workbook("HEENT.xlsx").sheet_by_index(0) med_name = [] for row in sheet.col(2): med_name.append(row) med_school = [] for row in sheet.col(3): med_school.append(row) mentor = [] for row in sheet.col(9): mentor.append(row)
I have managed to print the counts of my specific queries using Entrez.
from Bio import Entrez Entrez.email = "[email protected]" handle = Entrez.egquery(term="Jennifer Runch AND ((2012[Date - Publication] : 2017[Date - Publication])) ") handle_1 = Entrez.egquery(term = "Jennifer Runch AND ((2012[Date - Publication] : 2017[Date - Publication])) AND Leoard P. Byk") handle_2 = Entrez.egquery(term = "Jennifer Runch AND ((2012[Date - Publication] : 2017[Date - Publication])) AND Southern Illinois University School of Medicine") record = Entrez.read(handle) record_1 = Entrez.read(handle_1) record_2 = Entrez.read(handle_2) pubmed_count = [] for row in record["eGQueryResult"]: if row["DbName"] == "pubmed": pubmed_count.append(row["Count"]) for row in record_1["eGQueryResult"]: if row["DbName"] == "pubmed": pubmed_count.append(row["Count"]) for row in record_2["eGQueryResult"]: if row["DbName"] == "pubmed": pubmed_count.append(row["Count"]) print(pubmed_count) >>>['3', '0', '0']
The problem is that I need to replace the student name ("Jennifer Runch") with the next student name in the list of student names("med_name"), the medical school with the next school, and the current mentor's name with the next mentor's name from the list.
I think I should write a for loop after declaring my email to pubmed
, but I am not sure how to link the two blocks of code together. Does anyone know of an efficient way to connect the two blocks of code or know how to do this with a more efficient way than the one I have tried?
Thank you!