By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,778 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,778 IT Pros & Developers. It's quick & easy.

CSV file with Headers

P: n/a
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?

Dec 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
DW Marker wrote:
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?


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.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Dec 16 '05 #2

P: n/a
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

Dec 16 '05 #3

P: n/a
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.

Dec 16 '05 #4

P: n/a
DW Marker wrote:
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 ...

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Dec 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.