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
• 1,619 views
•
link
1 answer
- change query+'.txt' with year+query+'.txt'
- you didn't indent 'for query in termList:'
• 0 views
•
link
Log in to answer this question.