Nested loops write in xml
1
0
Entering edit mode
7.2 years ago
Lilizine ▴ 10

Hi all I want to write the output for each tuple ( year, term) in an xml format This is what I have done:

enteryears = range(2017, 2016, -1)
termList=["unmet ","needs"]  

 for year in years:
       for query in termList:
             xml_data=fetchByQuery(query,years)
              if xml_data==None: 
               print 80*"*"+"\n"
              print "This search returned no Pubmed Data"

       else:
        with open(query+str(year)+'.txt',"w") as temp_file:
                temp_file.write(xml_data(query,years))
                temp_file.close()

The issues: - The way I am writing the code it returns files with the query names without years and with the same content !

Thanks in advance

biopython python xml loop efetch • 1.3k views
ADD COMMENT
0
Entering edit mode
7.2 years ago
shoujun.gu ▴ 380
  1. change query+'.txt' with year+query+'.txt'
  2. you didn't indent 'for query in termList:'
ADD COMMENT

Login before adding your answer.

Traffic: 2683 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6