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

From Vibhor Kumar
Subject Re: How to Create Table from CSV
Date
Msg-id C74E3956-4336-4AEF-A151-E733D30C7582@enterprisedb.com
Whole thread Raw
In response to How to Create Table from CSV  (ray <ray@aarden.us>)
List pgsql-general
On Mar 7, 2011, at 12:13 AM, ray wrote:

>
> CREATE TABLE Equpment_List_Sheet2 FROM 'Equipment List, reference
> r1_Sheet2.csv' WITH DELIMITER ',' NULL '' CSV HEADER;
> ERROR:  syntax error at or near "FROM"
> LINE 1: CREATE TABLE Equpment_List_Sheet2 FROM 'Equipment List,
> refe...
>
> ^
> ********** Error **********
> ERROR: syntax error at or near "FROM"
> SQL state: 42601
> Character: 35
> ____________
> copy TABLE Equpment_List_Sheet2 FROM 'Equipment List, reference
> r1_Sheet2.csv' WITH DELIMITER ',' NULL '' CSV HEADER;
> ERROR:  syntax error at or near "TABLE"
> LINE 1: copy TABLE Equpment_List_Sheet2 FROM 'Equipment List,
> refere...
>                    ^
> ********** Error **********
> ERROR: syntax error at or near "TABLE"
> SQL state: 42601
> Character: 6



You can't create a table using CSV. However try following:
1. Create structure of table (Parse the column using some script or manually)
2. Import data using COPY Command.

Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
vibhor.kumar@enterprisedb.com
Blog:http://vibhork.blogspot.com


pgsql-general by date:

Previous
From: ray
Date:
Subject: How to Create Table from CSV
Next
From: Rich Shepard
Date:
Subject: Re: How to Create Table from CSV