parse and and print led
This commit is contained in:
34
scripts/parse_lb_ls.py
Normal file
34
scripts/parse_lb_ls.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import re
|
||||
|
||||
# Given text
|
||||
result_text = """
|
||||
LB1 23777
|
||||
LB2 24130
|
||||
LB3 23442
|
||||
LB4 23945
|
||||
LS1 2521
|
||||
LS2 973
|
||||
LS3 10252
|
||||
LS4 11017
|
||||
REND
|
||||
"""
|
||||
|
||||
# Define a regular expression pattern to extract LB1, LB2, LB3, and LB4 values
|
||||
pattern = re.compile(r'LB1 (\d+)\s+LB2 (\d+)\s+LB3 (\d+)\s+LB4 (\d+)')
|
||||
|
||||
# Search for the pattern in the text
|
||||
match = pattern.search(result_text)
|
||||
|
||||
# Extract values if the pattern is found
|
||||
if match:
|
||||
lb1_value = match.group(1)
|
||||
lb2_value = match.group(2)
|
||||
lb3_value = match.group(3)
|
||||
lb4_value = match.group(4)
|
||||
|
||||
print("LB1:", lb1_value)
|
||||
print("LB2:", lb2_value)
|
||||
print("LB3:", lb3_value)
|
||||
print("LB4:", lb4_value)
|
||||
else:
|
||||
print("Pattern not found.")
|
||||
Reference in New Issue
Block a user