I need to scrape the data from text file and insert it into xml template. This is the code am using..
inFile = open("Coler_Goldwater_Hospital_NY2013.txt", 'r')
outFile = open("coler_health.xml", "w")
buffer = []
for line in inFile:
if line.startswith("III. Health Needs Identified"):
#if ("Table 24 – Health Insurance Coverage, Baltimore City") in line:
buffer = ['']
elif line.startswith("IV. Community Assets Identified"):
outFile.write("".join(buffer))
buffer = []
elif buffer:
write
buffer.append(line)
inFile.close()
outFile.close()
the output is written into xml but I want data to insert into particular tag.
<?xml version="1.0" encoding="utf-8"?>
<xml>
<Priority Health Needs>
</Priority Health Needs>
<COMMUNITY ASSESSED>
</COMMUNITY ASSESSED>
</xml>
the text from the above python code should get be directly inserted into
<Priority Health Needs>
</Priority Health Needs>
Anyone, any changes to the code.. A little help over here..