Thread: Copy Comand question
Hi, I am using the copy command to create a .csv file, how do I include the table headings, or headings of my choice? The purpose of this paticular .csv file is to enable the users to download data from a web page and then report on it usingMS Excel. It works fine apart from not having any headings, which the users need as there can be a lot of data in the.csv file. Here is the command: <code snippet> \COPY temp_table TO $OUTFILE USING DELIMITERS ',' WITH NULL AS ' '; </code snippet> Regards, Sharon Cowling
On Sat, 2002-05-25 at 18:38, Sharon Cowling wrote: > Hi, > > I am using the copy command to create a .csv file, how do I include the table headings, or headings of my choice? > The purpose of this paticular .csv file is to enable the users to download data from a web page and then report on it usingMS Excel. It works fine apart from not having any headings, which the users need as there can be a lot of data in the.csv file. It's not possible. COPY is meant to dump raw data from a table. -- +---------------------------------------------------------+ | Ron Johnson, Jr. Home: ron.l.johnson@cox.net | | Jefferson, LA USA http://ronandheather.dhs.org:81 | | | | "I have created a government of whirled peas..." | | Maharishi Mahesh Yogi, 12-May-2002, | ! CNN, Larry King Live | +---------------------------------------------------------+
On Sunday 26 May 2002 04:22, you wrote: > On Sat, 2002-05-25 at 18:38, Sharon Cowling wrote: > > Hi, > > > > I am using the copy command to create a .csv file, how do I include the table headings, or headings of my choice? > > The purpose of this paticular .csv file is to enable the users to download data from a web page and then report on itusing MS Excel. It works fine apart from not having any headings, which the users need as there can be a lot of data inthe .csv file. > > It's not possible. COPY is meant to dump raw data from a table. > I know it is a bit of a bodge - but ... How about having a heading table. Then create a view which is a union to the two tables, and copy out the view. JohnT
How about doing the file generation using a scripting langugage (PHP, Perl, ...)? -------------------------------------------------------------- Rasmus T. Mohr Direct : +45 36 910 122 Application Developer Mobile : +45 28 731 827 Netpointers Intl. ApS Phone : +45 70 117 117 Vestergade 18 B Fax : +45 70 115 115 1456 Copenhagen K Email : mailto:rmo@netpointers.com Denmark Website : http://www.netpointers.com "Remember that there are no bugs, only undocumented features." -------------------------------------------------------------- > -----Original Message----- > From: pgsql-novice-owner@postgresql.org > [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of John Taylor > Sent: Monday, May 27, 2002 9:13 AM > To: Pgsql-Novice (E-mail) > Subject: Re: [NOVICE] Copy Comand question > > > On Sunday 26 May 2002 04:22, you wrote: > > On Sat, 2002-05-25 at 18:38, Sharon Cowling wrote: > > > Hi, > > > > > > I am using the copy command to create a .csv file, how do > I include the table headings, or headings of my choice? > > > The purpose of this paticular .csv file is to enable the > users to download data from a web page and then report on it > using MS Excel. It works fine apart from not having any > headings, which the users need as there can be a lot of data > in the .csv file. > > > > It's not possible. COPY is meant to dump raw data from a table. > > > > > I know it is a bit of a bodge - but ... > How about having a heading table. > Then create a view which is a union to the two tables, and > copy out the view. > > JohnT > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > >
Hi, I didn't think that copy did it, I'm adding the headings via a shell script. Thanks for your suggestion. Regards, Sharon Cowling Quoting John Taylor <postgres@jtresponse.co.uk>: > On Sunday 26 May 2002 04:22, you wrote: > > On Sat, 2002-05-25 at 18:38, Sharon Cowling wrote: > > > Hi, > > > > > > I am using the copy command to create a .csv file, how do I include the > table headings, or headings of my choice? > > > The purpose of this paticular .csv file is to enable the users to > download data from a web page and then report on it using MS Excel. It works > fine apart from not having any headings, which the users need as there can be > a lot of data in the .csv file. > > > > It's not possible. COPY is meant to dump raw data from a table. > > > > > I know it is a bit of a bodge - but ... > How about having a heading table. > Then create a view which is a union to the two tables, and copy out the > view. > > JohnT > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly > ------------------------------------------------- This mail sent through IMP: http://horde.org/imp/