Python Forum
Test a file for a string without opening it?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Test a file for a string without opening it?
#3
I was thinking to use a "break" if the first 'Run Time" line found.
Then reload the file again and process it to the end of the file.
something like this:
                with open(currentF) as mfiler:  
                    for ln in mfiler:
                        if runtime_l in ln :
                            ln=ln.rstrip()
                            print ("Run Time line FOUND__>", ln)
                            ftoiter = currentF                            
                            break 

                    with open(ftoiter) as mfile:  
                        for lns in mfile:
                            if runtime_l in lns :
                                print ("RUN TIME line++++++++++++++ >", lns)
                                print (lns)
Reply


Messages In This Thread
RE: Test a file for a string without opening it? - by tester_V - Jun-03-2020, 06:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need to replace a string with a file (HTML file) tester_V 1 1,907 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  unittest generates multiple files for each of my test case, how do I change to 1 file zsousa 0 1,622 Feb-15-2023, 05:34 PM
Last Post: zsousa
  How to sort .csv file test log which item first fail and paint color SamLiu 24 8,907 Sep-03-2022, 07:32 AM
Last Post: Pedroski55
  Facing Problem while opening a file through command prompt vlearner 4 3,148 Jan-30-2022, 08:10 AM
Last Post: snippsat
  How to test and import a model form computer to test accuracy using Sklearn library Anldra12 6 4,312 Jul-03-2021, 10:07 AM
Last Post: Anldra12
  How to make a test data file for the full length of definition? MDRI 6 4,839 Apr-16-2021, 01:47 AM
Last Post: MDRI
  Subprocesses not opening File Select Dialog teut 2 3,235 Feb-22-2021, 08:07 PM
Last Post: teut
  Writing unit test results into a text file ateestructural 3 6,773 Nov-15-2020, 05:41 PM
Last Post: ateestructural
  Opening file and outputting its text content example leodavinci1990 1 2,457 Oct-12-2020, 05:33 AM
Last Post: buran
  Print a certain string only the first time it appears in a test file buttercup 5 3,909 Jul-23-2020, 01:30 PM
Last Post: palladium

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020