I have some code that recompile a list into 2 separate lists using RegEx and re.compile. I want to repurpose this to create 3 lists one for the name one for the error and one for the %.
List = ['701, HealthyPI 85%, CM01_Verify Camera Not Ready 4%, UnknownPI 3%, CM01_Label Printer Fault 1.91%, CM01_Takeaway Conveyor Motor Fault 0.01%, UnknownPI|UnknownPI 0.00%, CM01_Kickout Conveyor Motor Fault 0.00%,,703, HealthyPI 48%, CM01_Label Printer Fault 0.84%, CM01_Grip_Servo_Axis_Fault 0.26%, UnknownPI 0.00%, CM01_Kickout Conveyor Motor Fault 0.00%,,704, HealthyPI 81%, CM01_Front Side Jaw Access Door Open 0.29%, UnknownPI 0.06%, CM01_Kickout Conveyor Motor Fault 0.01%,,705, HealthyPI 39%, CM01_Label Printer Fault 1.25%, CM01_Bubble Film Roll Out of Position 0.83%, CM01_Sealing Jaw Not Clear 0.02%, UnknownPI 0.00%,,706, HealthyPI 42%, CM01_Label Printer Fault 1.45%, UnknownPI 0.00%,,707, HealthyPI 44%, CM01_Label Printer Fault 1.36%, CM01_Bubble Film Roll Out of Position 0.91%, CM01_Nip Roller Retracted during Run Attempt 0.13%, CM01_Product Sensor Not Clear 0.03%, UnknownPI 0.00%,,708, CM01_Verify Camera Not Ready 13%,,710, HealthyPI 33%, CM01_Bubble Film Roll Out of Position 1.14%, UnknownPI 0.00%,,712, HealthyPI 10%, CM01_Label Printer Fault 2%, UnknownPI 0.00%,,713, HealthyPI 21%, CM01_Nip Roller Retracted during Run Attempt 0.19%, CM01_Back Side Exit Conveyor
E-Stop Pressed 0.02%, UnknownPI 0.00%, CM01_Kickout Conveyor Motor Fault 0.00%,']
Current Code :
list_1 = ['SmartPac']
list_2 = ['Availability']
for string in list:
temp = re.compile("(,|^)((\d+)(\.\d+)?)(,|$)").findall(string)
list_1 += [x[1] for x in temp]
temp = re.compile("(,|^)((\d+)(\.\d+)?%)(,|$)").findall(string)
list_2 += [x[1] for x in temp]
Desired output:
List_Name = ['701', '703', '704', '705', '706', '707', '708', '710', '712', '713']
List_ERROR = ['HealthyPI','CM01_Verify Camera Not Ready','UnknownPI',etc]
List_% = ['85%','4%','3%',etc]
I want to be able to complete a table by column of list one . There can be more then one error per equipment name and the follow %.