Hi,
I am beginner in Python and I'm looking for a method to write to a file by using Index.
This is my program:
**************************************************************
infile = open("land1.txt","r")
outfile = open('out.txt', 'w')
text = infile.read()
infile.close()
search = "<CgPoint"
found=text.find(search)
while found > -1:
print search, "found at location", found
found=text.find(search, found+1)
****************************************************************
This program can give me the index of each line. Then I have extract the coordinates from the line and write it to another file.
and land1.txt is something like this (an XML file):
*************************************************************************************
<CgPoint oID="7824186" state="existing" pntSurv="boundary" name="AX">232.661082515329 226.070442386027</CgPoint>
<CgPoint oID="7825374" state="existing" pntSurv="boundary" name="AN">233.294671906327 256.064262174272</CgPoint>
<CgPoint oID="7825082" state="existing" pntSurv="boundary" name="BE">369.65460238028 224.374211320059</CgPoint>
<CgPoint oID="7816689" state="existing" pntSurv="boundary" name="BV">329.0034454898 3.55174522463776</CgPoint>
<CgPoint oID="7825549" state="existing" pntSurv="boundary" name="BQ">369.734427409734 235.727500401241</CgPoint>
*******************************************************************
Attention: Sometime the above mentioned lines are in one line and whole the file is a very big line.
So I want to extract the red characters and produce something like this:
AX 232.661082515329 226.070442386027
AN 233.294671906327 256.064262174272
BE 369.65460238028 224.374211320059
BV 329.0034454898 3.55174522463776
BQ 369.734427409734 235.727500401241
******************************************************************************
Thanks for your help and advice.
Regards