Re: How to Create Table from CSV - Mailing list pgsql-general

From Rich Shepard
Subject Re: How to Create Table from CSV
Date
Msg-id alpine.LNX.2.00.1103061117030.23837@salmo.appl-ecosys.com
Whole thread Raw
In response to How to Create Table from CSV  (ray <ray@aarden.us>)
List pgsql-general
On Sun, 6 Mar 2011, ray wrote:

> I would like to create a table from a CSV file (the first line is
> headers which I want to use as column names) saved from Excel.  I have
> a new database which I have been able to create tables from a
> tutorial.  But I haven?t been able to produce this new table.  The
> following are my attempts:

   As mentioned, write the table structure to a file using the postgres DDL.
That is, 'CREATE TABLE <name> (
             column1...
           );'

Then using psql you can '\copy to <tablename> from <filename> with delimiter
as ',' null as '' CSV' (without the quotes and with appropriate delimiter
and null values. The backslash is needed to make it work.

Rich

pgsql-general by date:

Previous
From: Vibhor Kumar
Date:
Subject: Re: How to Create Table from CSV
Next
From: Eduardo
Date:
Subject: Re: Web Hosting