Question: Nested loops write in xml
0
gravatar for Lilizine
23 months ago by
Lilizine0
Lilizine0 wrote:

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

xml efetch biopython loop python • 571 views
ADD COMMENTlink modified 23 months ago • written 23 months ago by Lilizine0
0
gravatar for shoujun.gu
23 months ago by
shoujun.gu370
Rockville/MD
shoujun.gu370 wrote:
  1. change query+'.txt' with year+query+'.txt'
  2. you didn't indent 'for query in termList:'
ADD COMMENTlink written 23 months ago by shoujun.gu370
Please log in to add an answer.

Help
Access

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