This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Nested loops write in xml

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 answer

  1. change query+'.txt' with year+query+'.txt'
  2. you didn't indent 'for query in termList:'

Log in to answer this question.