Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-04 Thread Peter Otten
Mohan Mohta wrote: > Hello, > I am trying to grep the keyword (which I got from report_file ) from > report_file > > I tried multiple ways but am unable to get it to work. > > Below are the methods I tried. > > > fp=open(txt_file,'r') > for line in fp : > line=line.strip() >

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-04 Thread Chris Angelico
On Fri, Jan 4, 2019 at 10:16 PM wrote: > > On Thursday, January 3, 2019 at 9:40:43 PM UTC+1, Chris Angelico wrote: > > On Fri, Jan 4, 2019 at 7:37 AM Mohan Mohta wrote: > > > I am no expert in python but I found grep is lot faster in than the > > > methods of reading files from python point

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-04 Thread marco . nawijn
On Thursday, January 3, 2019 at 9:40:43 PM UTC+1, Chris Angelico wrote: > On Fri, Jan 4, 2019 at 7:37 AM Mohan Mohta wrote: > > I am no expert in python but I found grep is lot faster in than the methods > > of reading files from python point me to direction if you know of > > anything

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-03 Thread Chris Angelico
On Fri, Jan 4, 2019 at 7:37 AM Mohan Mohta wrote: > I am no expert in python but I found grep is lot faster in than the methods > of reading files from python point me to direction if you know of > anything faster I would appreciate it. > Try doing things the simple and easy way in Python,

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-03 Thread Mohan Mohta
On Thursday, January 3, 2019 at 1:49:31 PM UTC-6, Chris Angelico wrote: > On Fri, Jan 4, 2019 at 6:46 AM Mohan Mohta wrote: > > > > Hello, > > I am trying to grep the keyword (which I got from report_file ) from > > report_file > > > > I tried multiple ways but am unable to get it to work. > >

RE: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-03 Thread David Raymond
Agreeing with the other poster that it's probably not the best way to handle it. But for the sake of helping with subprocess: https://docs.python.org/3.7/library/subprocess.html#popen-objects Popen Objects don't have read() as the error says. That's on their .stdout and .stderr streams. So

Re: subprocess : AttributeError: 'Popen' object has no attribute 'read'

2019-01-03 Thread Chris Angelico
On Fri, Jan 4, 2019 at 6:46 AM Mohan Mohta wrote: > > Hello, > I am trying to grep the keyword (which I got from report_file ) from > report_file > > I tried multiple ways but am unable to get it to work. How about, instead, you simply open the file and iterate through it, looking for the