Hi,
The input file structure is given below: The Col1 and Col2 will be there always. But from Col3 there can be more columns.
And Col3 will be always Col4 and Col5 will always be with Col6. I need to replace the | with comma. There are scnearios where there
wont be no data.Below, the row 2 does not have data for col5,col6,col6,col8. I am using the command
cat Testin1|sed -e 's/||/,,,/g' -e 's/|/,/g'
How i use this command to achieve my requirement Or what is the best way to handle this?
Input:
Col1,Col2|Col3,Col4|Col5,Col6|Col7,Col8
Market1,"Chain1"|3,3|3,3|3,3|3,3
Market1,"Chain1"|3,3|||
Market1,"Chain1"||3,3||
Market1,"Chain1"|||3,3|
Market1,"Chain1"||||3,3
Expected Output:
Market1,"Chain1",3,3,3,3,3,3,3,3
Market1,"Chain1",3,3,,,,,,,
Market1,"Chain1",,,3,3,,,,,
Market1,"Chain1",,,,,3,3,,,
Market1,"Chain1",,,,,,,3,3
Current Output:
Market1,"Chain1",3,3,3,3,3,3,3,3
Market1,"Chain1",3,3,,,,
Market1,"Chain1",,,3,3,,,
Market1,"Chain1",,,,3,3,
Market1,"Chain1",,,,,,3,3
Thanks,
bharathappriyan