Re: python read line by line and keep indent

2020-04-18 Thread Souvik Dutta
Oh! Sorry I didn't get that earlier. 😛 On Sat, 18 Apr, 2020, 9:10 pm MRAB, wrote: > On 2020-04-18 08:59, Souvik Dutta wrote: > > Okay so I was not able to say properly. You are indeed doing the same > thing > > that you were doing i.e. writting the modified data just, that now you > > don't need

Re: python read line by line and keep indent

2020-04-18 Thread MRAB
On 2020-04-18 08:59, Souvik Dutta wrote: Okay so I was not able to say properly. You are indeed doing the same thing that you were doing i.e. writting the modified data just, that now you don't need to close you if file before doing any writting stuff. That is there is a one line deduction from t

Re: python read line by line and keep indent

2020-04-18 Thread Souvik Dutta
Okay so I was not able to say properly. You are indeed doing the same thing that you were doing i.e. writting the modified data just, that now you don't need to close you if file before doing any writting stuff. That is there is a one line deduction from the whole code. Souvik flutter dev On Sat,

Re: python read line by line and keep indent

2020-04-18 Thread Peter Otten
Souvik Dutta wrote: > You can actually read and write in a file simultaneously. Just replace "r" > with "w+" if the file has not been previously made or use "r+" is the file > has already been made. Good advice for those who like to butcher their data ;) Seriously, writing modified data into a n

Re: python read line by line and keep indent

2020-04-17 Thread Souvik Dutta
You can actually read and write in a file simultaneously. Just replace "r" with "w+" if the file has not been previously made or use "r+" is the file has already been made. Souvik flutter dev On Sat, Apr 18, 2020, 4:45 AM wrote: > Hi; > > I am reading a Python file and find an specific line, re

Re: python read line by line and keep indent

2020-04-17 Thread DL Neil via Python-list
On 18/04/20 11:10 AM, hnasr9...@gmail.com wrote: I am reading a Python file and find an specific line, replace a text and then write back to the file. When I check back the file, I am getting indent error. How to fix this issue. Please make it easier for us (volunteers giving-up our free ti

Re: python read line by line and keep indent

2020-04-17 Thread Greg Ewing
On 18/04/20 11:10 am, hnasr9...@gmail.com wrote: Hi; I am reading a Python file and find an specific line, replace a text and then write back to the file. When I check back the file, I am getting indent error. It looks like your script is stripping out all the indentation when it writes the

python read line by line and keep indent

2020-04-17 Thread hnasr9999
Hi; I am reading a Python file and find an specific line, replace a text and then write back to the file. When I check back the file, I am getting indent error. How to fix this issue. reading_file = open("myfile.py", "r") new_file_content = "" for line in reading_file:

Re: read line

2008-05-06 Thread Larry Bates
[EMAIL PROTECTED] wrote: hi every body, I'm a new python user and I'm making a program to run useing Abaqus and there is something I can't do, if i have a text file that has a line like this " 10 20 30 40 50" and I wana do the coding to put every number of these like 10 or 20 in a separa

Re: read line

2008-05-06 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > hi every body, > > I'm a new python user and I'm making a program to run useing Abaqus > and there is something I can't do, > > if i have a text file that has a line like this " 10 20 30 40 > 50" and I wana do the coding to put every number of these like 10 or >

read line

2008-05-06 Thread moustafa . elmihy
hi every body, I'm a new python user and I'm making a program to run useing Abaqus and there is something I can't do, if i have a text file that has a line like this " 10 20 30 40 50" and I wana do the coding to put every number of these like 10 or 20 in a separate variable .. any suggesti

Re: How do i read line from an input file, without the /n

2005-12-14 Thread Gerard Flanagan
doritrieur wrote: > can anyone > refer me to an online source that supplies the relevant data for syntax http://rgruet.free.fr/PQR2.3.html http://www.google.com -- http://mail.python.org/mailman/listinfo/python-list

Re: How do i read line from an input file, without the /n

2005-12-14 Thread doritrieur
thanks all for your replies! it did helped me! by the way, i am really new to phyton and to programming, can anyone refer me to an online source that supplies the relevant data for syntax ect? thanks, Dorit. -- http://mail.python.org/mailman/listinfo/python-list

Re: How do i read line from an input file, without the /n

2005-12-13 Thread Fredrik Lundh
"doritrieur" <[EMAIL PROTECTED]> wrote: > How do i read line from an input file, without the /n ? > the readline function returns also the /n character at the end. i need > to read a line without the training /n so strip if off! line = line[:-1] # remove l

Re: How do i read line from an input file, without the /n

2005-12-13 Thread Aggelos Orfanakos
f.readline().rstrip('\n') should do it. If you are sure that lines always end in '\n', then you could even use f.readline()[:-1] -- http://mail.python.org/mailman/listinfo/python-list

How do i read line from an input file, without the /n

2005-12-13 Thread doritrieur
How do i read line from an input file, without the /n ? the readline function returns also the /n character at the end. i need to read a line without the training /n is this possible? thanks, Dorit -- http://mail.python.org/mailman/listinfo/python-list