I am trying to classiffy some logs to further analyze them in Python Pandas. A log sample would look like:
Event: Task_01Error:NO_ERROR
Event: Task_01Error:ERROR_MINOR
Event: Task_02Error:NO_ERROR
Event: Task_03Error:ERROR_01Details:BadData
Event: Task_03Error:ERROR_MINOR
I need to classify them as (my desired output):
Task, ErrorType,Details
01,NO_ERROR,NA
01,ERROR_MINOR,NA
02,NO_ERROR,NA
03,ERROR_01,BadData
03,ERROR_MINOR,NA
What I have come with so far is:
^Event: Task_(.*)Error:(.*)Details:(.*$)
Which only matches the fourth entry (as expected). But I actually need it to match either the information after the "Details:" string or nothing if the string is not there. The reason I need it that way is so I can use the regular expression with Pandas Series String Extract.
In other words, In the last group I need to match:
Details:(.*$) OR ()
I know there must be an easy way to do this but I just cannot figure it out.
Thanks!