On Sun, 24 May 2009 19:46:01 +0100, Alexzive <zasaconsult...@gmail.com>
wrote:
Hello,
I am a newby with python. I wrote the following code to extract a text
from a file and write it to another file:
linestring = open(path, 'r').read() #read all the inp file in
linestring
i=linestring.index("*NODE")
i=linestring.index("E",i)
e=linestring.index("*",i+10)
textN = linestring[i+2:e-1] # crop the ELement+nodes list
Nfile = open("N.txt", "w")
Nfile.write(textN)
unfortunately when I check N.txt some lines are missing (it only crop
until "57, 0.231749688431, 0.0405121944142" but I espect the final
line to be "242, 0.2979675, 0.224605896461". I check textN and it has
all the lines until "242..")
when I try Nfile.write(textN) again it writes some more lines but
still not all!
what is wrong whit this?
Cutting and pasting (and substituting the sample file for `path`),
it works for me on Python 2.6.2 (Ubuntu Linux). It must be something
to do with the context you're calling the code in. Are you checking
the output before the program has finished running or something?
--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list