Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / December 2005

Tip: Looking for answers? Try searching our database.

CSV file with Headers

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DW Marker - 15 Dec 2005 23:30 GMT
All -

I am trying to figure out how to get a comma delimited file from the
command line which includes the column headings as the first line.  I
know how to create a del file using export, but it doesn't put the
headings.  I also know I could redirect the output from a select, but a
select isn't comma delimited... Any ideas?
Knut Stolze - 16 Dec 2005 07:23 GMT
> All -
>
[quoted text clipped - 3 lines]
> headings.  I also know I could redirect the output from a select, but a
> select isn't comma delimited... Any ideas?

Lots of options:

(1) write to the file and phrase the query in the export in such a way that
the first row produces the required headings
(2) use EXPORT and subsequently modify the file to prepend the header
(3) use a simple SELECT statement, redirect the output to a file, and along
the way ensure that the first row contains the header.  You can do that by
redirecting two SELECT statements to the same file.
(4) Use a separate file for the header.  That avoids the whole issue from
the beginning.

Signature

Knut Stolze
DB2 Information Integration Development
IBM Germany

DW Marker - 16 Dec 2005 15:49 GMT
But is there a simple way to comma delimit a simple seldct statement..
The problem here is that I have to have a CSV file
Brian Tkatch - 16 Dec 2005 17:23 GMT
The EXPORT command to DEL puts the delimiters in, as for the headers,
just add it manually to EXPORT's query with a UNION.

B.
Knut Stolze - 16 Dec 2005 19:56 GMT
> But is there a simple way to comma delimit a simple seldct statement..
> The problem here is that I have to have a CSV file

I guess there is a "no" missing somewhere in your sentence?

Adding the commas is quite easy:

SELECT col1, ',', col2, ',', col3
FROM   ...

Signature

Knut Stolze
DB2 Information Integration Development
IBM Germany

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.