You would want to write a program to do this (don’t know if you are capable of this or not).
Non-programming techniques are problematic because there is really no way to verify sequential numbers on successive lines.
It could be done if you didn’t need this verification. In this case one presumes that what comes after the bottom line on the left is something with a different pattern than the four lines shown. Thus the 42 in the first line could be “grabbed” and the 45 in the fourth line could be grabbed, and the single line could be constructed and replace the set of 4 lines.
Only you know your data, and you’d need a better problem statement for better help.