473,545 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CSV file with Headers

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
4 9215
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
2656
by: edykstra | last post by:
Hello, If you point your browser to this page, http://prdownloads.sourceforge.net/vnc-tight/tightvnc-1.2.9_x86_viewer.zip?use_mirror=umn the server sends you the HTML page, and very soon afterwards, you are prompted to do a 'Save-As' for a file to download. How do they do that without the classic "Headers already sent" error?
2
3017
by: Oleg Ogurok | last post by:
Hi all, On my web page, I have a <OBJECT DATA="mydatafile.ica" ...> which loads Citrix ICA web client. The problem is that I want to generate the mydatafile.ica on the fly (e.g. based on session variables) and pass it to the user. So I was thinking of doing it this way: <OBJECT DATA="datafilegen.asp" ...>
6
21049
by: Omid | last post by:
Hi. I have problems when I try to redirect everything that is sent to cout to a file. I have one piece of code that works and one that does not work. The only difference is which headers I use. What the code does: * First writes "This is sent to prompt" to prompt.
4
15041
by: Exits Funnel | last post by:
Hello, I'm slightly confused about when to use parens around #included files and when to use angle brackets. I understand (I think) that the difference is that the compiler will search in its standard include directories for files included as <file> but not for those included as "file". It's clear to me then that headers for the standard...
9
1505
by: comp.lang.php | last post by:
<?php if (headers_sent()) print_r('headers sent'); // do other stuff ?> I have a file, "classes.inc.php", a library of PHP version 4+ classes. This library file, the moment it is included, causes headers to be generated into the HTTP headers! I have no explanation as to how it does that, it just does that! I have tried everything I...
6
414
by: rony_16 | last post by:
Hi, I have problem with downloading a file using WebRequest and HttpWebResponse. Inorder to download this file i need to call to url that tells to prepare the file for download, and then i call to another url that downloads the file. I have a problem with that because: 1. i do not know when the server finished the preparetion. 2.i...
1
3482
by: krishan123456 | last post by:
i have tried to send email with attached doc file but when i receive the mail i find the attached file in encoded text instead of actuall attachment.the code that i used to send an email is given below. function SendMail123($From,$FromName,$To,$ToName,$Subject,$Text,$Html,$AttmFiles){ $OB="----=_OuterBoundary_000";...
3
1847
by: andersond | last post by:
I have a PHP file that usually sends an email. Instead, it now simply displays the code beginning with line 14 (where #eol= begins). Can anybody help me with this? <?php #Change only the information after the equals sign $to = $_REQUEST; $body = "Your request to bind the submission on ".$_REQUEST." has been received by...
2
4274
by: Erik Witkop | last post by:
So I have been trying to get this to work all day. I can't get a local file on my web server to attach to an email. Right now I have it printing out in the body of the email. Please help me with any thouhgts on how to get it in as an attachment. CODE: <?php ini_set(SMTP, "172.18.1.65");
8
28333
blazedaces
by: blazedaces | last post by:
So I have a program below which writes an excel file with multiple sheets based on inputs of sheet names, data, cell types, etc. It uses Apache POI, which is currently the only thing I found (correct me if I'm wrong about this) that can write excel 2007 files. The program works. I've tested it out on very small files (I will include the...
0
7499
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7943
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7786
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6022
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.