Convert to excel

Hi to all the tycoons of Shell programming!!

I am getting a csv report out of a query and the report is delimited with '|' symbol. I would like to convert this csv report into an xls column wise.. Let me show u an example as below

Say a.csv looks like below

Number|Description|Cycle|Date
3456|This is for the release uvhfiuvhorojpjp|Production|13-03-08
12354|iufviurhrhogtjobvjrjpjk|UAT|26-02-08

I would like to convert the same into excel column wise automatically (see the attachment for details).. I pretty well know that if we open the file in csv it will opt us with delimiter options, but i want that to be automatic in the script itself.. Is there any option in unix to achieve that?

Please help me out.. Thanks in advance..

Please try this,

 sed -ne 's/|/,/g' YourInput > /tmp/out.csv

Thanks
Nagarajan G

Hi Nagarajan,

Thanks for your time.. But the above command doesn't seem to be working :frowning:

sed -ne 's/|/,/g' test > test.csv

I executed the command as in the above line, wherein test contains the data as in my initial mail. You can see test.csv with 0 bytes.. I am afraid that it didnit write anything to it.. :frowning:

/home/ganagdhar$ ls -ltr test*
-rw-rw-r-- 1 gangadhar root 746 28 Sep 06:49 test.sh
-rw-r----- 1 gangadhar root 86 17 Jan 08:02 test
-rw-rw-r-- 1 gangadhar root 0 18 Jan 01:46 test.csv

try this...

while read line ;do echo $line | tr "|" , ; done < a.csv >> out.csv

may not be of that smart!!

-ilan

tr "|" "," < a.csv > out.csv

wow!! ghostdog.. it worked pretty well..

thanks to all for ur timely help..

Sorry i missed to print that..

 sed -ne 's/|/,/gp' YourInput > /tmp/out.csv

Thanks
Nagarajan G