Converting varied space delimited file to Pipedemilited

Hi all,

I have source file, data looks like

12345  abc   def   01 / 001200    C     2000
12345  abc   def   01 / 001200    C           2500
12345  abcd  def   01 / 001200    C                     3500
18945  xyz     pqr   01 / 009900   D     4000  5000   2800      9900

Expected ouput shall be

12345|abc|def|01 / 001200|C|2000||||
12345|abc|def|01 / 001200|C ||2500||
12345|abc|def|01 / 001200|C|||3500|
18945|xyz|pqr|01 / 009900|D|4000|5000|2800|9900

Space between the fields is varying.
Please help in framing the code.

Thanks in advance
Raj

 
sed -e 's: / :~:' -e 's: *:|:g' -e 's:~: / :' filename
sed -e 's: / :~:' -e 's: *:|:g' -e 's:~: / :' filename

This is not giving the expected output.

Why does the C in line two of your sample output have a space with it? Why does the first line have five trailing (numeric/empty) fields, all others only four? And, unless the number of spaces separating/representing the numbers is always identical (which it is not the case in your example), there won't be a chance to get the numbers into the right columns.