Re: [Tutor] Read lines opening with a particular set of characters from a file

2015-11-29 Thread Br. Sayan
It is exactly what Peter has said. Opened the file with 'U' and it worked like a charm. Thank you very much! On 28 November 2015 at 19:10, Peter Otten <__pete...@web.de> wrote: > Br. Sayan wrote: > > > I am doing the following : > > > > with open('Manwal.txt') as infile, open('Manwal_req.txt','

Re: [Tutor] Read lines opening with a particular set of characters from a file

2015-11-28 Thread Peter Otten
Br. Sayan wrote: > I am doing the following : > > with open('Manwal.txt') as infile, open('Manwal_req.txt','w') as outfile: > for line in infile: > if line.startswith(('R')): > outfile.write(line) > > It is executing without error but returns a blank file. Where is the >

Re: [Tutor] Read lines opening with a particular set of characters from a file

2015-11-28 Thread Alan Gauld
On 28/11/15 11:22, Br. Sayan wrote: > I am doing the following : > > with open('Manwal.txt') as infile, open('Manwal_req.txt','w') as outfile: > for line in infile: > if line.startswith(('R')): > outfile.write(line) > > It is executing without error but returns a blank fil

Re: [Tutor] Read lines opening with a particular set of characters from a file

2015-11-28 Thread Br. Sayan
I am doing the following : with open('Manwal.txt') as infile, open('Manwal_req.txt','w') as outfile: for line in infile: if line.startswith(('R')): outfile.write(line) It is executing without error but returns a blank file. Where is the problem? On 27 November 2015 at 22:

Re: [Tutor] Read lines opening with a particular set of characters from a file

2015-11-28 Thread Laura Creighton
In a message of Sat, 28 Nov 2015 16:52:07 +0530, "Br. Sayan" writes: >I am doing the following : > >with open('Manwal.txt') as infile, open('Manwal_req.txt','w') as outfile: >for line in infile: >if line.startswith(('R')): >outfile.write(line) > >It is executing without erro

Re: [Tutor] Read lines opening with a particular set of characters from a file

2015-11-27 Thread Laura Creighton
In a message of Fri, 27 Nov 2015 17:05:21 +0530, "Br. Sayan" writes: >How can we read specific lines from a text files using python. File >attached. > >Suppose we want to read lines starting with 'R|1|^^^' and 'O|1|' > >Should we use: > >line.startswith(("..", "..", "")) that matches lines tha

[Tutor] Read lines opening with a particular set of characters from a file

2015-11-27 Thread Br. Sayan
How can we read specific lines from a text files using python. File attached. Suppose we want to read lines starting with 'R|1|^^^' and 'O|1|' Should we use: line.startswith(("..", "..", "")) H|\^&|||C311^1|host|RSUPL^BATCH|P|1 P|1 O|1|9060^MANWAL ^1^^010|R1|^^^989/\^^^99