Writing in excel sheet using ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Writing in excel sheet using ksh
# 1  
Old 05-14-2014
Writing in excel sheet using ksh

Hello,

I'm trying to write a script to export a txt file to excel. The text file is a delimited with commas

Example:
Code:
Report Date,12/12/2014
Report By, Person
Issue, Job Failed

I tried exporting as csv and mailed to my id. But if I open the csv file the data is coming in single column.

Output I'm getting:
Code:
Column A
Report Date,12/12/2014
Report By, Person
Issue, Job Failed

But I'm expecting below output
Code:
Column A      Column B
Report Date   12/12/2014
Report By      Person
Issue            Job Failed

I checked the forum. I'm getting examples to export txt to csv which gives the similar result as what I'm getting. I dont have perl so I need a solution to get the above output using ksh


Could someone please help.

Last edited by Franklin52; 05-14-2014 at 07:21 AM.. Reason: Please use code tags
# 2  
Old 05-14-2014
I believe excel defaults to tab rather than comma separation, so a simple sed 's/,/\t/g' <file.txt> should work, no?
This User Gave Thanks to Skrynesaver For This Post:
# 3  
Old 05-14-2014
Naming the file to with .csv extension works for me. First, its automatically associated with excel and fields are correctly parsed.
This User Gave Thanks to clx For This Post:
# 4  
Old 05-14-2014
If you save it with a .txt suffix and then open it with Excel, it will start the wizard where you can define the columns and how you import it. Mark it as delimited and check the comma selection.


Robin
This User Gave Thanks to rbatte1 For This Post:
# 5  
Old 05-14-2014
Tabs actually work much, much better since they don't appear in data as often as commas do.

Make sure your lines end in \r\n if you're importing into Excel.
This User Gave Thanks to Corona688 For This Post:
# 6  
Old 05-14-2014
Thanks everyone. Tab space is working fine....
# 7  
Old 05-14-2014
I have written a number of shell scripts that generated .csv files and emailed them out. Generally I use the double quote comma delimiter. As in:

"col1","col2","col3","col4"...

That might work as well, since you still might get a tab in your data.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Writing xml from excel sheet .xls using perl script

Hi all. I am working on the below requirement of generating .xml file from .xls file which i have , can someone please help me or in writing the perl script for the same: The xls file format is as below which has two columns and number of rows are not fixed: Fixlet Name ... (12 Replies)
Discussion started by: omkar.jadhav
12 Replies

2. Shell Programming and Scripting

Summing up the data from different excel sheet into one excel sheet

Hi Folks, Can you please advise for any script in unix such that for example , i have 3 different excel sheet at the location /ppt/gfr/exc so the name s of the excel sheet are 1excel.xslx 2excel.xslx 3excel.xslx now in these 3 different excel sheet there is lot of data for example each... (3 Replies)
Discussion started by: punpun66
3 Replies

3. Windows & DOS: Issues & Discussions

Comparing two columns in same Excel sheet

Hi, I have a great doubt in Lotus Symphony Spread Sheet (Hope its similar to Excel) Am new to this Lotus Symphony Please tell me a formula to compare two columns in Excel (Lotus Symphony Spread Sheet) The columns contain strings. Eg., "Column E" and "Column AO" needs to be compared Like... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies

4. Shell Programming and Scripting

Format Excel sheet

Hi, I want to format Excel sheet through Unix script. Format would mean bolding the data in the cell, adding clor to it etc. Please help me if it is possible through Unix scripting? Thanks, Durga (2 Replies)
Discussion started by: Durga Prasad NK
2 Replies

5. Shell Programming and Scripting

Perl : to get all the hyperlinks from the xlsx sheet(hyperlinks not visible in excel sheet directly)

Hi folks, I have a requirement in perl to print all the hyperlink from the spreadsheet(xlsx). Spreadsheet contains few lines of hyperlink data (pic attached). P.S. Hyperlink is behind the data and not visible in excel sheet directly. Now using perl script I need to copy the hyperlinks in... (3 Replies)
Discussion started by: scriptscript
3 Replies

6. Shell Programming and Scripting

Pdf to excel sheet??

Hi everyone, I want a shellscript code that takes an pdf as input and returns the data in the pdf into an excel sheet... Thanks, C10 (3 Replies)
Discussion started by: Carlton
3 Replies

7. Shell Programming and Scripting

Adding Tab to excel Sheet

Hi, I have 2 sets of data in two different files,say f1 and f2. I want to create a excel sheet with two tabs whose names will be set at run time(different from excel name) in a shell script, and the data will be written into those two tabs at run time.Any command in UNIX doing so? I am... (7 Replies)
Discussion started by: Kishore_1
7 Replies

8. Shell Programming and Scripting

Excel sheet to be created from unix.

Hi Guys, I like to create a excel sheet with four tabs. Is it possible to create it. Acutually i want to apply formulas in fourth tab which uses the three different tabs. Is it possible to create such a script? Thanks & regards, Magesh (3 Replies)
Discussion started by: mac4rfree
3 Replies

9. Solaris

Excel sheet

Hello, I have an information of about 100 odd file names which i have in my server. I need to attach this information in an excel sheet and sent to the concerned team. I use uuencode for attaching a text file. But how will i have all the information in attachment. Please assist. Is there... (1 Reply)
Discussion started by: venkidhadha
1 Replies

10. HP-UX

Creating Excel Sheet in Hp-UX

Dear Members, How do I create an eqvivalant of Excel sheet in Hp-UX. Is there any application like the Microsoft Excel on HP-UX. How do I invoke it. Regards, PrasadKVS (5 Replies)
Discussion started by: KVSPRASAD
5 Replies
Login or Register to Ask a Question