what is wrong with my code?

i want to download abstracts of research paper from pubmed

and eliminate '.' and divide them by ' '

so i write this code:

for pubmed_id in record['IdList']:

        abstract = Entrez.efetch('pubmed', id=pubmed_id, retmode='text', rettype='abstracts')

        downloaded_abstracts.append(abstract)

      

keywords_in_abstract = []

for ab in downloaded_abstracts:

        keyword_box = []

        words = ab.replace('.', '').split(' ')

        for w in words:

                if w.upper() == disease:

                        keyword_box.append(w.upper())

                else:

                        if w in name_kegg:

                                keyword_box.append( name_kegg[w] )

                     

        keywords_in_abstract.append(keyword_box)

=================

but this error happens.

Traceback (most recent call last):

  File "C:/python/home.py", line 55, in

    words = ab.replace('.', '').split(' ')

builtins.AttributeError: '_io.TextIOWrapper' object has no attribute 'replace'

====================

How can I solve this problem?

Answers 0

Related Articles