Log Transformation

I am trying to transform a log into process mining log. The second image shows the raw data, the first image shows the expected output.

I am basically trying to merge 3 rows into one row with the values. but if there is an error in the raw data like absence of expected flow. i would like to discard that particular data.

Thank you in advance