pipeline delimiter issue having constraints

107 Views Asked by At

I need a code or a program to edit a csv-file where the following conditions should hold:

  1. The no. of pipes | in each row / line should be 14

  2. If 14 pipes are not present the there must be the data which has moved to the following lines. So I need to trim those lines and merge them with the previous line to ensure having 14 pipes.


Sample data from csv-file (added due to comments):

  • Correct line:

    ab|bfgc|cd|gfdgde|ef|fg|gh|hi|jdsfk|kl|lm|mfdgn|nq|ql|df
    
  • Wrong line:

    dkflmd|bgbfdsfD|Sfsddf|efdgfdg sdfsd|dfgdf|gfdhdfh|gfdg| sdfs|gdf| sdgdf
    gfdgedf|dfy|
    

Some of the data in the first line of the wrong code has been shifted to the next line so I need a program which can trim from the next line and append to the previous line.

0

There are 0 best solutions below