I have two codes in the text file( 001 & 002) if row starts with 002 code the row amount should be added with the next 001 code row amount. The sequence should be repeated for each 001 code row. means every 001 code row amount should be the sum with the previous 002-row amount(i.e b/w each 001 code row the amount should be concatenated with next 001-row amount)
Actual rows from the input file
001 | 0.00
002 | 10.5
002 | 5.0
001 | 0.00
002 | 15.0
001 | 5
002 | 7
001 | 2
Expected output rows from the input file
001 | 0.00
002 | 10.5
002 | 5.0
001 | 15.5 ( adding amount with 2nd, 3rd-row amount)
002 | 15.0
001 | 20.0 (adding amount with previous 002 code amount)
002 | 7.0
001 | 9.0 (adding amount with previous 002 code amount)