Re: [Tutor] Example for read and readlines() (Asad)

2018-11-13 Thread Avi Gross
g or worse. Good luck. -Original Message- From: Tutor On Behalf Of Asad Sent: Sunday, November 11, 2018 8:54 PM To: tutor@python.org Subject: Re: [Tutor] Example for read and readlines() (Asad) Hi All , Thanks for the reply . I am building a framework for the two error conditions, t

Re: [Tutor] Example for read and readlines() (Asad)

2018-11-13 Thread Cameron Simpson
On 12Nov2018 07:24, Asad wrote: Thanks for the reply . I am building a framework for the two error conditions, therefore I need to read and readlines because in one only regex is required and in other regex+ n-1 line is required to process : #Here we are opening the file and

Re: [Tutor] Example for read and readlines() (Asad)

2018-11-12 Thread Asad
/www.alan-g.me.uk/ > http://www.amazon.com/author/alan_gauld > Follow my photo-blog on Flickr at: > http://www.flickr.com/photos/alangauldphotos > > > > > > > -- Forwarded message -- > From: Alan Gauld > To: tutor@python.org > Cc: > Bcc: >

Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Alan Gauld via Tutor
On 11/11/2018 10:04, Asad wrote: > 1) and I want to extract the start time , error number and end > time from this logfile so in this case what should I use I guess option 1 : > > with open(filename, 'r') as f: > for line in f: > process(line) Yes, that woyuld be the best

Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Alan Gauld via Tutor
On 11/11/2018 09:40, Steven D'Aprano wrote: >> f3 = open ( r"/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log", 'r' ) > > Don't use raw strings r"..." for pathnames. Umm, Why not? -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/

Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Alan Gauld via Tutor
On 11/11/2018 06:49, Asad wrote: > Hi All , > > If I am loading a logfile what should I use from the option 1,2,3 > > f3 = open ( r"/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log", 'r' ) > > 1) should only iterate over f3 This is best for processing line by line which is the

Re: [Tutor] Example for read and readlines()

2018-11-11 Thread Steven D'Aprano
On Sun, Nov 11, 2018 at 12:19:36PM +0530, Asad wrote: > Hi All , > > If I am loading a logfile what should I use from the option 1,2,3 Depends what you want to do. I assume that the log file is formatted into lines of text, so you probably want to iterate over each line. with