Nov-16-2022, 08:30 PM
Greetings!
I'm searching lines for two words "PASSED" and "FAILED"
I need to get the line before "PASSED" and the "FAILED" line.
I'm definitely doing it wrong,
the script I wrote does not get me the line I'm looking for, it actually prints the same line.
Thank you!
I'm searching lines for two words "PASSED" and "FAILED"
I need to get the line before "PASSED" and the "FAILED" line.
I'm definitely doing it wrong,
the script I wrote does not get me the line I'm looking for, it actually prints the same line.
ftor = open('C:/01/prt.csv','r') for num, el in enumerate(ftor, 1): el=el.strip() if 'PASSED' in el : to_gt =num-1 print(f" BEFORE PASSED ->{to_gt} - {el}") pas_fail = el.split(",") print (f" {num} {pas_fail[9]} - {el}") print("") elif 'FAILED' in el : to_gt =num-1 print(f" BEFORE FAILED ->{to_gt} - {el}") pas_fail = el.split(",") print (f" {num} {pas_fail[9]} - {el}") print("") ftor.close()
Thank you!