Spooling data from the database in .csv file with boundary


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Spooling data from the database in .csv file with boundary
# 1  
Old 04-02-2014
Spooling data from the database in .csv file with boundary

Hi Guys,

Another questions to the genius over here. I have spool the dataf from the database into a .csv file. But can it be possible to have all the rows and column with the boundaries..for example the .csv file which i have is as below:

Code:
20140327 BU 9A 3 
20140327 SPACE 9A 3 
20140327 BU 9F 33 
20140327 SPACE 9F 33 
20140327 BU 9L 17 
20140327 SPACE 9L 18

The allignment is not good in the above and that's why i am thinking to put these values into the boundaries. Can it be possible guys...



Thanks in Advance
Pramod

Last edited by Pramod_009; 04-02-2014 at 01:17 PM.. Reason: The output was not coming as per the requirement.
# 2  
Old 04-02-2014
Without seeing the output you want, it's difficult to tell, but you could try changing spaces into tabs:

Code:
# Quick example
$ tr ' ' '\t' <<EOF
> 20140327 BU 9A 3
> 20140327 SPACE 9A 3
> 20140327 BU 9F 33
> 20140327 SPACE 9F 33
> 20140327 BU 9L 17
> 20140327 SPACE 9L 18
> EOF
20140327        BU      9A      3
20140327        SPACE   9A      3
20140327        BU      9F      33
20140327        SPACE   9F      33
20140327        BU      9L      17
20140327        SPACE   9L      18

# How you'd probably use it
$ tr ' ' '\t' < inputfile > outputfile

# 3  
Old 04-02-2014
Hi,

I would be probably putting the boundaries exactly similar to the microsoft excel as i need to send the content of the file instead the file.

Thanks
# 4  
Old 04-02-2014
A CSV file is supposed to be a Comma Separated Values file.

So I would suggest to set colsep to comma before spooling:
Code:
set colsep ,

# 5  
Old 04-02-2014
How does one send the "content of" a file without sending a file?

Please show the output you want, we're not having any luck just guessing.
# 6  
Old 04-02-2014
Hi Yoda,

I have already tried with the colsep, but the thing is, since the data is small, so i just wanted to be pooled out from the database and send these data in a tabular format in the message body.

Please suggest me if anything can be done on this.

Thanks in Advance...
Pramod
# 7  
Old 04-02-2014
I repeat:
Quote:
Originally Posted by Corona688
Please show the output you want, we're not having any luck just guessing.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare 2 files of csv file and match column data and create a new csv file of them

Hi, I am newbie in shell script. I need your help to solve my problem. Firstly, I have 2 files of csv and i want to compare of the contents then the output will be written in a new csv file. File1: SourceFile,DateTimeOriginal /home/intannf/foto/IMG_0713.JPG,2015:02:17 11:14:07... (8 Replies)
Discussion started by: refrain
8 Replies

2. Shell Programming and Scripting

Korn shell program to parse CSV text file and insert values into Oracle database

Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database. I need to write the korn shell program on Red Hat Enterprise Linux server. Oracle database is 10g. (15 Replies)
Discussion started by: shellguy
15 Replies

3. Shell Programming and Scripting

Execute stored procedure through script in sybase database and store the output in a .csv file

Hi, I have a sybase stored procedure which takes two input parameters (start_date and end_date) and when it get executed, it gives few records as an output. I want to write a unix script (ksh) which login to the sybase database, then execute this stored procedure (takes the input parameter as... (8 Replies)
Discussion started by: amit.mathur08
8 Replies

4. UNIX and Linux Applications

Retrieving data from a database and store to a file

Hi I'm using and Oracle 10g Database. I want to write a script to retrieve data from the database and store it toa file. I'm using simple sql statements such as Select * from celltable I don't know how to specify the database name etc. I have this but it doesn't work ... (1 Reply)
Discussion started by: ladyAnne
1 Replies

5. Shell Programming and Scripting

Help with loading data from DB2 database to CSV file

Hi everyone!! I need help regarding this. How can we load data from DB2 Database tables into a Comma Separated File? I also have another Question? Using Shell scripting, Is it easy to read Data from a table or from a text file? It is very urgent for me. Please help me out guys. ... (1 Reply)
Discussion started by: ss3944
1 Replies

6. Shell Programming and Scripting

Reading data from DataBase and Writing to a file

Hi All, Please help me in writing data to a file in one row. In database there is a column which contains large data which does not fit in the file in one row. The column contains list of paths. I want to write these paths to a file in one row. Please find the code below writes : ... (2 Replies)
Discussion started by: rajeshorpu
2 Replies

7. UNIX for Dummies Questions & Answers

Option in sql script to include column headers when spooling file to .csv format

Can anyone help me how to include COLUMN HEADER when spooling file to .CSV format through SQL statement. Thanks, Akbar (4 Replies)
Discussion started by: s1a2m3
4 Replies

8. UNIX for Dummies Questions & Answers

Shell scripting+connect to oracle database+spooling

Hi! Everyone I am new to the shell scripting basically.I have been asked to create a shell script that connect to a oracle database to read data from a particular schema then spool it into a csv file then email to customer. Can anybody let me know how to go about that. I have create... (14 Replies)
Discussion started by: Mr Mo
14 Replies

9. Shell Programming and Scripting

Shell Script to Load data into the database using a .csv file and .ctl file

Since i'm new to scripting i'm findind it difficult to code a script. The script has to be an executable with 2 paramters passed to it.The Parameters are 1. The Control file name(.ctl file) 2. The Data file name(.csv file) Does anybody have an idea about it? :confused: (3 Replies)
Discussion started by: Csmani
3 Replies

10. Shell Programming and Scripting

unix script to export data from csv file to oracle database

Hello people, Need favour. The problem I have is that, I need to develop a unix shell script that performs recurring exports of data from a csv file to an oracle database. Basically, the csv file contains just the first name and last name will be dumped to an Unix server. The data from these... (3 Replies)
Discussion started by: vinayagan
3 Replies
Login or Register to Ask a Question