Re: How to Create Table from CSV

From: "ray joseph" <ray(at)aarden(dot)us>
To: "'Dimitri Fontaine'" <dimitri(at)2ndQuadrant(dot)fr>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to Create Table from CSV
Date: 2011-03-07 01:38:30
Message-ID: 0947F8B1BA924E60A883FB790AF1E5F8@corp.kbr.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I appreciate all the information

Thank you,
ray

-----Original Message-----
From: Dimitri Fontaine [mailto:dimitri(at)2ndQuadrant(dot)fr]
Sent: Sunday, March 06, 2011 3:19 PM
To: ray
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] How to Create Table from CSV

ray <ray(at)aarden(dot)us> writes:
> 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

You have to manually create the table and its columns, as other said.
The tricky part that is hard (or impossible) to automate is deciding
which data type to use for each column.

Once you've done that, actually importing the data is a matter of using
the COPY command or the pgloader tool.

In PostgreSQL 9.1 you will be able to use CREATE FOREIGN TABLE to
achieve that in one step, see:

CREATE FOREIGN TABLE

http://developer.postgresql.org/pgdocs/postgres/ddl-foreign-data.html

http://developer.postgresql.org/pgdocs/postgres/sql-createforeigndatawrapper
.html
http://developer.postgresql.org/pgdocs/postgres/file-fdw.html

Regards,
--
Dimitri Fontaine
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rob Sargent 2011-03-07 04:49:44 Re: School teacher in need of HELP
Previous Message Adrian Klaver 2011-03-07 00:35:07 Re: Deleted database from pgAdmin