Hi all ,

        Can you provide some advice and code for the following problem :

I have a logfile to check for errors :

/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log

f3 = open ( r"/a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log", 'r' )
st1 = f3.readlines ()

from the above log I extract the directory location to determine the
location of  another log  using the following regular expresssion:

for j in range ( len ( st1 ) ):
   patchnumber = re.compile(r'(\d+)\/(\d+)')

   mo = patchnumber.search (st1[j-1])
   a = mo.group()   ## 123456/789
   ===================================================================
   How to do I traverse to the required directory which is
/a/b/c/d/test/123456/789 ?

   1) First I need to extract /a/b/c/d/test/  from
 /a/b/c/d/test/test_2814__2018_10_05_12_12_45/logA.log  ?
   2) Then add 123456/789 and create directory location as
/a/b/c/d/test/123456/789
   3) cd /a/b/c/d/test/123456/789
   4) look for the latest file in the directory  /a/b/c/d/test/123456/789
   5) print its content

Please advice ,
-- 
Asad Hasan
+91 9582111698
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to