Re: writing on file not until the end

2009-05-25 Thread Dave Angel
Alessandro wrote: I closed and restarted the python console. Now this code (with added "Nfile.close()" at the end) seems to work properly: linestring = open(path, 'r').read() i=linestring.index("*NODE") i=linestring.index("E",i) e=linestring.index("*",i+10) textN = linestring[i+2:e-1] Nfile =

Re: writing on file not until the end

2009-05-25 Thread Alessandro
On May 25, 10:58 am, John Machin wrote: > On May 25, 6:30 pm, Alessandro wrote: > > > > > On May 25, 8:38 am, Peter Otten <__pete...@web.de> wrote: > > > > Alexzive wrote: > > > > I am a newby with python. I wrote the following code to extract a text > > > > from a file and write it to another fi

Re: writing on file not until the end

2009-05-25 Thread John Machin
On May 25, 6:30 pm, Alessandro wrote: > On May 25, 8:38 am, Peter Otten <__pete...@web.de> wrote: > > > > > Alexzive wrote: > > > 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

Re: writing on file not until the end

2009-05-25 Thread Peter Otten
Alessandro wrote: > - until now, the only solution which works is to repeat the code while > the file is still open, which means a quite redundant code: > > linestring = open(path, 'r').read() > i=linestring.index("*NODE") > i=linestring.index("E",i) > e=linestring.index("*",i+10) > textN = lines

Re: writing on file not until the end

2009-05-25 Thread Alessandro
On May 25, 8:38 am, Peter Otten <__pete...@web.de> wrote: > Alexzive wrote: > > 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.

Re: writing on file not until the end

2009-05-24 Thread Peter Otten
Alexzive wrote: > 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("*"

Re: writing on file not until the end

2009-05-24 Thread Dave Angel
Alexzive 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) tex

Re: writing on file not until the end

2009-05-24 Thread Rhodri James
On Sun, 24 May 2009 19:46:01 +0100, Alexzive 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

Re: writing on file not until the end

2009-05-24 Thread Benjamin Kaplan
On Sun, May 24, 2009 at 2:46 PM, Alexzive 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=linestr

writing on file not until the end

2009-05-24 Thread Alexzive
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+