Question: problem in code to retrieve articles titles from pubmed
gravatar for dreamzz.4you
4.0 years ago by
dreamzz.4you0 wrote:

Hi there,

i am trying to fetch author names and articles' titles from pubmed. The only issue in this code is, it is giving title of articles in this form: ['R', 'o', 'u', 't', 'i', 'n', 'e', ' ', 'A', 'm', 'o', 'x', 'i', 'c', 'i', 'l', 'l', 'i', 'n', ' ', 'f', 'o', 'r', ' ', 'U', 'n', 'c', 'o', 'm', 'p', 'l', 'i', 'c', 'a', 't', 'e', ']

i mean separating each character with ' '. i want to get the names in a proper way. I am learner of python. please anyone help me out.


from Bio import Entrez
from Bio import Medline

TERM = '[si]'

#print("getting %d publications containing %s" % (MAX_COUNT,TERM))

print('Getting {0} publications containing {1}...'.format(MAX_COUNT, TERM)) = ''
h = Entrez.esearch(db='pubmed', retmax=MAX_COUNT, term=TERM)
result =
print('Total number of publications containing {0}: {1}'.format(TERM, result['Count']))

ids = result['IdList']
h = Entrez.efetch(db='pubmed', id=ids, rettype="Medline", retmode='text')
records = Medline.parse(h)

authors = []
for record in records:
    au = record.get('AU', '?')
   # print(au)
    for a in au:
        #if a,b not in authors,t:
    for t in title:
print('Authors: {0} '.format(', '.join(authors)))

problem in code • 1.1k views
ADD COMMENTlink modified 3.9 years ago by Biostar ♦♦ 20 • written 4.0 years ago by dreamzz.4you0

I am not a Python programmer but assuming that the variable title contains only one title then this code:

    for t in title:

is taking single elements of title (i.e. characters) and adds then to an array named titles so titles ends up being a list of characters contained in title. Just stick to your title variable and if you want to add it to a list of titles then do

ADD REPLYlink modified 4.0 years ago • written 4.0 years ago by Jean-Karim Heriche21k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2080 users visited in the last hour