How to extract UNIX output to excel CSV file?

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to extract UNIX output to excel CSV file?
# 1  
How to extract UNIX output to excel CSV file?

Hi guys - I have a file and output like this below:

File: myfile.dat
File has content like this: ABCD, 34, 456, 2324
I would like excel to have this:
Name (ABCD) Quantity (34), Type (456), Status (2324)
(Name, Quantity, Type and Status are columns)

I would like to export this file to excel. What command to use to email myself as CSV format?


Last edited by DallasT; 05-06-2014 at 03:04 PM..
# 2  
What do you want the output to look like?
This User Gave Thanks to Corona688 For This Post:
# 3  
Like this (if possible), thanks.

Name Quantity Type Status
ABCD 34          456  2324
XYX  24          21X T

# 4  
Your file practically is that already. Add carriage returns, load it into excel as CSV, and see what you get.

( printf "Name,Quantity,Type,Status\r\n" ; sed 's/$/\r/g' ) < input > output.csv

This User Gave Thanks to Corona688 For This Post:
# 5  
With some assumption that your file might look like this...
$ cat file
Name (ABCD) Quantity (34), Type (456), Status (2324)

$ cat tester
awk  'FNR==1{
		print head
		head = head "|,|[()]"
		$1 = $1
	    }1' head="Name,Quantity,Type,Status" OFS="\t" file

$ ./tester
Name	Quantity  Type	Status
ABCD	34	   456	 2324

For csv replace OFS="\t" with OFS=","
This User Gave Thanks to Akshay Hegde For This Post:

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #334
Difficulty: Easy
For security reasons, Android versions are not named in alphabetical order.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Extract UNIX data to excel

Hi, I would like to extract the data from particular date, 1. may i know which command i need to use? 2. Extract from unix command (those extracted above) to excel? Please assist. Thanks (2 Replies)
Discussion started by: Peru
2 Replies

2. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

3. Shell Programming and Scripting

How to extract data into excel from a database in unix

Hello viewers, I am connecting to db2 database from unix. I am executing a query for example select * from emp. I need to export the data obtained from the above command to a excel file. Could you please suggest how to proceed on this? thanks and regards, k.n.v.santosh (3 Replies)
Discussion started by: santoshaarudhra
3 Replies

4. UNIX for Dummies Questions & Answers

Excel File to CSV

Hi All, I have to convert the excel file which will be placed in the Unix box to a CSV file using a shell script. Please Advise. Thanks & Regards, Kumar66 (1 Reply)
Discussion started by: kumar66
1 Replies

5. Shell Programming and Scripting

How to convert a excel file to a .csv file from unix script

Hi I have a excel file in unix machine and have to convert it into a .csv file.I have to do this from a unix script.How do we do this? Thanks Abhinav (3 Replies)
Discussion started by: akashtcs
3 Replies

6. UNIX for Advanced & Expert Users

Problem in converting password protected excel file to csv file in unix

I need to convert a password protected excel file which will be in UNIX server to a comma separated file. For this I need to open the excel file in UNIX box but the UNIX box doesn’t prompt for password instead it is opened in an encrypted manner. I could manually ftp the excel file to local... (2 Replies)
Discussion started by: Devivish
2 Replies

7. Shell Programming and Scripting

Add multiple .csv files as sheets to an excel file in unix.

Hi, I am using Solaris 8. My script outputs 4 .csv files. Currently I am SFTPing the files and creating a new excel file with the 4 files as sheets. Can anyone suggest ways to do this in UNIX ? Thanks, David. (2 Replies)
Discussion started by: libin4u2000
2 Replies

8. UNIX for Advanced & Expert Users

Unix Shell Script with output to CSV File

Hi, I have a unix shell script that is outputting results from an SQL query to a *.csv file, using utl_file.put_line. The resulting file is then sent out via e-mail as a mail attachment. The issue I have is that when the mailed attachment is opened in Excel the first column is shown as... (1 Reply)
Discussion started by: heather.morton@
1 Replies

9. Shell Programming and Scripting

text file to excel or csv

Hi, I have a text file like ---------------------- aaa|bbb|ccc|ddd|eee fff|gggg|hhhhhh|kkkk -------------------- I have a script which will transfer(thourgh FTP) this text file to windows system. But I want to covert it into excel or CSF then upload into windows system.. thanks (9 Replies)
Discussion started by: srikanthus2002
9 Replies

10. UNIX for Advanced & Expert Users

Updating a csv file held on a unix box with excel running on windows

Hi, my question is quite simple: Can I update a csv file which is held on a unix box (and which a script on the same box uses) with Microsoft Excel running in a windows environment? Or, is there a free spreadsheet package available to run in unix that will update my csv file. I know it's easy to... (5 Replies)
Discussion started by: Sn33R
5 Replies

Featured Tech Videos