Convert to excel


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert to excel
# 1  
Old 01-17-2008
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..
Convert to excel-crlistjpg
# 2  
Old 01-17-2008
Please try this,
Code:
 sed -ne 's/|/,/g' YourInput > /tmp/out.csv

Thanks
Nagarajan G
# 3  
Old 01-18-2008
Quote:
Originally Posted by ennstate
Please try this,
Code:
 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 Smilie

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.. Smilie

/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
# 4  
Old 01-18-2008
try this...

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

may not be of that smart!!

-ilan
# 5  
Old 01-18-2008
Quote:
Originally Posted by ilan
try this...

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

may not be of that smart!!

-ilan
Code:
tr "|" "," < a.csv > out.csv

# 6  
Old 01-18-2008
wow!! ghostdog.. it worked pretty well..

thanks to all for ur timely help..
# 7  
Old 01-18-2008
Quote:
Originally Posted by ennstate
Please try this,
Code:
 sed -ne 's/|/,/g' YourInput > /tmp/out.csv

Thanks
Nagarajan G
Sorry i missed to print that..
Code:
 sed -ne 's/|/,/gp' YourInput > /tmp/out.csv


Thanks
Nagarajan G
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert excel to tab

Hello, I have an excel sheet (.xlsx), with 11 worksheets. I need to run my bash scripts on the 1st worksheet and write the output to the 2nd worksheet. I am currently manually converting the worksheet into a tab delimited to run the script and then pasting it back to excel. Is there a way to do... (2 Replies)
Discussion started by: nans
2 Replies

2. Shell Programming and Scripting

Convert excel to csv in python date not display exactly

Hi, Anyone can help I am just converting the excel file to csv using python, I can get the conversion output but the date not display exactly. test.xlsx date format 167 1588 risks/SCS JP CAMPANA & CIE.pdf SCS JP CAMPANA & CIE 2 1 1 0 2015-03-16 16:56:25 167 1146 risks/AirBNB... (1 Reply)
Discussion started by: fspalero
1 Replies

3. Shell Programming and Scripting

Need to convert text file into Excel sheet

:cool:Hi, Iam new to this Scripts and forum too. Plz excuse if may i ask silly questions now and further.. Prob: i need to convert txt files data into excel sheet. Suppose if i have hour-wise data in txt file1 and file2 like file1 file2 00: 140 00: 235 01: 160 01:415... (1 Reply)
Discussion started by: mrudula
1 Replies

4. UNIX for Dummies Questions & Answers

Convert csv to excel

Hi All, I have a csv file in unix and I need to convert it into excel formate. Please help me out (1 Reply)
Discussion started by: Abhisrajput
1 Replies

5. Shell Programming and Scripting

How to convert Excel Files to Xls?

Hi All, I have created a BI Publisher report in Oracle apps R12. It has generated the output with *.EXCEL file extension. I have a shell script to mail this output. in my shell script I have copied this file and saved as *.xls file. But the R12 generated *.EXCEL file is not a real excel... (5 Replies)
Discussion started by: kalidoss
5 Replies

6. Shell Programming and Scripting

Convert array data to excel format

I need your help in changing the script I have data has below text file :> cat my_emp Employee array(0) Name : Albert No : 1234 Address: stationstraat City: Utrecht Employee array (1) Name : Kouwen No : 1256 Address: stationstraat City: Amsterdam Employee array (2) Name : Peter... (2 Replies)
Discussion started by: LinuxLearner
2 Replies

7. Shell Programming and Scripting

Need to convert the content of file into COLUMN (To export into excel)

I have multiple condition in file as below. MONITOR "ALERT_INFO" DESCRIPTION "Triggered when informational Netware alert occured" MAXTHRESHOLD 95 SEVERITY Normal MONITOR "ALERT_MAJOR" DESCRIPTION "Triggered when major Netware alert occured" MAXTHRESHOLD SEVERITY Major I need to... (6 Replies)
Discussion started by: velocitnitin
6 Replies

8. UNIX for Advanced & Expert Users

how to convert text/csv to excel

Hello All, I have a sql report with 50 columns and 1000 rows result in a file ( txt / csv). is there is any way that we can move them to excel in KSH. Thanks, Sateesh (7 Replies)
Discussion started by: kotasateesh
7 Replies

9. Shell Programming and Scripting

Convert each field to excel

Hi Folks!! I would like to convert each and every output of my query to the excel column wise. Let me give you an example The first attachment (cr.jpg) is the one which i am getting out of a query and the fields are delimited with a '|' (pipe) symbol. I would like to convert each field into a... (4 Replies)
Discussion started by: ganga.dharan
4 Replies

10. Shell Programming and Scripting

convert Text to Excel

I have some text data generated by a perl script and want to put it into an excel sheet. Is there a perl script that can do this for me, i.e, convert text data to excel? (1 Reply)
Discussion started by: Pavankk
1 Replies
Login or Register to Ask a Question