Problems in string replacement

S

saif.shakeel

HI,
Thanks for the reply.that seems to work,but i was doing this
so as to attach it to a bigger code where it will be utilised before
a
parsing.

#Input file and Output file path from user


file_input = raw_input("Enter The ODX File Path:")


(shortname,ext)=os.path.splitext(file_input)
f_open_out=shortname+".ini"
log=shortname+".xls"
test_file=shortname+"testxml.xml"


saveout = sys.stdout


input_xml = open(file_input,'r')
xmlcont=input_xml.read()
xmlcont=xmlcont.replace('localId','dataPackageId')
output_file = open(test_file,"w")
output_file.write(xmlcont)
output_file.close()


f_open=open(f_open_out, 'w')
logfile=open(log,"w")


sys.stdout = f_open


#Parse the input file,and check for correct ODX version


xmldoc = minidom.parse(input_xml)


I am opening 2 more files in addition to the file
where the new xml goes.One file is written using the sys.stdout
command as most of the output has to go there printing takes place in
many places (so cant use f_open.write) each time.
When i attach the part of replacing the string
'localid' in xml file with something else as given above with
xmlcont=xmlcont.replace('localId','dataPackageId')
the code does not run and hangs.Can more than 3 files be opened at a
time .I dotn know what the problem is here.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Unusual i/o problems 6
i/o prob revisited 3
Element tree errors 1
replacing string in xml file 6
replacing string in xml file--revisited 7
I/O Error 1
Memory problems (garbage collection) 6
XML expat error 6

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top