Shell Script for converting file to Excel or CSV


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script for converting file to Excel or CSV
# 1  
Old 04-04-2013
Shell Script for converting file to Excel or CSV

Hi I have a dat file which has "n" number of columns. The file is delimited. The number of columns keep varying as the file is generated out of DB queries. Could you please help me in writing a script which will generate a XLS or CSV file out of the dat file.
# 2  
Old 04-04-2013
Turning your DAT into a CSV simply means changing your delimiters from whatever they are now, into commas. CSV = "comma separated values".

If your data contains commas, you may need to quote the sections.

What is your delimiter?
# 3  
Old 04-04-2013
If your data is spooled from DB, you can create a CSV output by setting the column separator to comma in SQL:
Code:
set colsep ,

# 4  
Old 04-04-2013
Corona- the delimiter would be \t.

The query is being run in a tool(ETL_Abinitio).
# 5  
Old 04-04-2013
Code:
awk -F'\t' '{$1=$1}1' OFS=, file

# 6  
Old 04-04-2013
If your data doesn't contain commas:
Code:
tr ',' '\t' < inputfile | sed 's/$/\r/' > outputfile

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tabbed multiple csv files into one single excel file with using shell script not perl

Hi Experts, I am querying backup status results for multiple databases and getting each and every database result in one csv file. so i need to combine all csv files in one excel file with separate tabs. I am not familiar with perl script so i am using shell script. Could anyone please... (4 Replies)
Discussion started by: ramakrk2
4 Replies

2. Shell Programming and Scripting

Error while Converting Excel to CSV using xls2csv

I am using xls2csv to convert a xls file into a regular .csv file. However, while using the command as xls2csv fromfile.xls > tofile.csv I am getting the following error. fromfile.xls is not OLE file or Error I also tried to specify the comma as delimiter but did not help... xls2csv -c\,... (7 Replies)
Discussion started by: dhruuv369
7 Replies

3. UNIX for Dummies Questions & Answers

How to Create excel file(.csv) using shell script?

Hi, i have shell script which compiles n number of test cases and execute them one by one. i want to create report in excel through script in which two columns namely "test id" and "release".second column have two subcolumns namely compiles and excutes. so i want first column should display test... (15 Replies)
Discussion started by: RamMore123
15 Replies

4. Shell Programming and Scripting

Converting specific Excel file tabs to CSV in Python

Hi list, This is probably something really simple, but I am not particularly familiar with Python so I thought I would ask as I know that python has an excel module. I have an excel document with multiple tabs of data and graphs. One of the tabs is just data which I require to have dumped to... (8 Replies)
Discussion started by: landossa
8 Replies

5. Shell Programming and Scripting

KSH - Text from input file truncated while converting it to excel

Dear Members, I am using the attached script to convert a input file delimited by '|' to excel. However, while processing the attribute change_reason, the whole content of the text under change_reason is not displayed completely in the cell in excel. It is truncated after only first few words.... (1 Reply)
Discussion started by: Yoodit
1 Replies

6. Shell Programming and Scripting

Shell script - Excel/CSV file - More than one tab

Hi All, Following is my requirement. I have searched the site and found some threads which has same queries, but non of them have any answer. I thought of posting it once more. We are generating different reports through shell script after we finish our data load. Currently there are 7 such... (5 Replies)
Discussion started by: ace_friends22
5 Replies

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

8. Shell Programming and Scripting

editing excel file through shell script

Hi, I am having a business file in excel having charts based on data already present on it. I would like to add new rows after the existing data and refesh the chart on it using shell script. For example-- In excel file in "sheet1", There is some data in first 10 rows ( from column A to F).... (0 Replies)
Discussion started by: sanjay1979
0 Replies

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

10. Shell Programming and Scripting

Shell script for converting file contents into CSV

Hi, I am new in unix, I just want to replace some values from text file according to column numbers. Like, I am having a table as given below: val1 val2 val3 val4 val5 val6 val7 val8 val9 val10 val11 val12 val13 Now i want... (5 Replies)
Discussion started by: rish_max
5 Replies
Login or Register to Ask a Question