Re: COPY command - CSV files

Lists: pgsql-hackers
From: Umberto Zappi <uzappi(at)inwind(dot)it>
To: pgsql-hackers(at)postgresql(dot)org
Subject: COPY command - CSV files
Date: 2004-05-02 15:03:35
Message-ID: 40950DC7.4070609@inwind.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I wish modify COPY command for support of CSV files (dump/load files in
CSV format).
I think this option is very important from import data from spreedsheet
as OpenOffice/calc or M$/excel.
I have found this task in TODO list, also.

I've begin my work, modify COPY syntax in:

COPY tablename [ ( column [, ...] ) ]
FROM { 'filename' | STDIN }
[ [ WITH ]
[ BINARY ]
[ OIDS ]
[ DELIMITER [ AS ] 'delimiter' ]
[ [ OPTIONALLY ] ENCLOSED [ BY ] 'delimiter1' [ AND
'delimiter2' ] ]
[ NULL [ AS ] 'null string' ] ]

COPY tablename [ ( column [, ...] ) ]
TO { 'filename' | STDOUT }
[ [ WITH ]
[ BINARY ]
[ OIDS ]
[ DELIMITER [ AS ] 'delimiter' ]
[ ENCLOSED [ BY ] 'delimiter1' [ AND 'delimiter2' ] ]
[ NULL [ AS ] 'null string' ] ]

Syntax is like to control-file of Oracle's utility sql*load.
Enclosed define the first and second delimiters (if are different)
which surround each field.
The delimiters may be optionally if keyword exists.

At soon!
Umberto Zappi.


From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY command - CSV files
Date: 2004-05-05 16:40:56
Message-ID: 40991918.9070800@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


It's been done already.

see http://developer.postgresql.org/todo.php and
http://developer.postgresql.org/docs/postgres/sql-copy.html

cheers

andrew

Umberto Zappi wrote:

> I wish modify COPY command for support of CSV files (dump/load files in
> CSV format).
> I think this option is very important from import data from spreedsheet
> as OpenOffice/calc or M$/excel.
> I have found this task in TODO list, also.
>
> I've begin my work, modify COPY syntax in:
>
> COPY tablename [ ( column [, ...] ) ]
> FROM { 'filename' | STDIN }
> [ [ WITH ]
> [ BINARY ]
> [ OIDS ]
> [ DELIMITER [ AS ] 'delimiter' ]
> [ [ OPTIONALLY ] ENCLOSED [ BY ] 'delimiter1' [ AND
> 'delimiter2' ] ]
> [ NULL [ AS ] 'null string' ] ]
>
> COPY tablename [ ( column [, ...] ) ]
> TO { 'filename' | STDOUT }
> [ [ WITH ]
> [ BINARY ]
> [ OIDS ]
> [ DELIMITER [ AS ] 'delimiter' ]
> [ ENCLOSED [ BY ] 'delimiter1' [ AND 'delimiter2' ] ]
> [ NULL [ AS ] 'null string' ] ]
>
> Syntax is like to control-file of Oracle's utility sql*load.
> Enclosed define the first and second delimiters (if are different)
> which surround each field.
> The delimiters may be optionally if keyword exists.
>
> At soon!
> Umberto Zappi.
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY command - CSV files
Date: 2004-05-05 16:48:48
Message-ID: 200405051648.i45GmmV14560@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Umberto Zappi wrote:
> I wish modify COPY command for support of CSV files (dump/load files in
> CSV format).
> I think this option is very important from import data from spreedsheet
> as OpenOffice/calc or M$/excel.
> I have found this task in TODO list, also.
>
> I've begin my work, modify COPY syntax in:
>
> COPY tablename [ ( column [, ...] ) ]
> FROM { 'filename' | STDIN }
> [ [ WITH ]
> [ BINARY ]
> [ OIDS ]
> [ DELIMITER [ AS ] 'delimiter' ]
> [ [ OPTIONALLY ] ENCLOSED [ BY ] 'delimiter1' [ AND
> 'delimiter2' ] ]
> [ NULL [ AS ] 'null string' ] ]
>
> COPY tablename [ ( column [, ...] ) ]
> TO { 'filename' | STDOUT }
> [ [ WITH ]
> [ BINARY ]
> [ OIDS ]
> [ DELIMITER [ AS ] 'delimiter' ]
> [ ENCLOSED [ BY ] 'delimiter1' [ AND 'delimiter2' ] ]
> [ NULL [ AS ] 'null string' ] ]
>
> Syntax is like to control-file of Oracle's utility sql*load.
> Enclosed define the first and second delimiters (if are different)
> which surround each field.
> The delimiters may be optionally if keyword exists.

I guess you didn't notice that the TODO item has a dash next it, meaning
it is done and will be in 7.5. We didn't use Oracle's syntax, but we do
allow for the escape character in the quotes to be specified if different:

COPY tablename [ ( column [, ...] ) ] ]' ]
FROM { 'filename' | STDIN }elimiter' ] ...] ]
[ [ WITH ] S ] AS ] 'null string' ]' ]
[ BINARY ] [ AS ] 'delimiter' ] ...] ]
[ OIDS ] AS ] 'null string' ]' ]
[ DELIMITER [ AS ] 'delimiter' ] ...] ]
[ NULL [ AS ] 'null string' ]' ]
[ CSV [ QUOTE [ AS ] 'quote' ] , ...] ]
[ ESCAPE [ AS ] 'escape' ]
[ FORCE NOT NULL column [, ...] ]
TO { 'filename' | STDOUT }delimiter' ]

COPY tablename [ ( column [, ...] ) ] ]' ]
TO { 'filename' | STDOUT }delimiter' ]
[ [ WITH ] S ] AS ] 'null string' ]' ]
[ BINARY ]R [ AS ] 'delimiter' ]
[ OIDS ] AS ] 'null string' ]' ]
[ DELIMITER [ AS ] 'delimiter' ]
[ NULL [ AS ] 'null string' ]' ]
[ CSV [ QUOTE [ AS ] 'quote' ]
[ ESCAPE [ AS ] 'escape' ]

One interesting idea we had was for ,, to be null, and ,"", to be a
zero-length string. You can control that with FORCE NOT NULL,
meaning ,, is a zero-length string too.

To get the full details, see the current docs on the developers web
page.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Umberto Zappi <uzappi(at)inwind(dot)it>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY command - CSV files
Date: 2004-05-05 16:55:11
Message-ID: 20040505165511.GA24911@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, May 02, 2004 at 17:03:35 +0200,
Umberto Zappi <uzappi(at)inwind(dot)it> wrote:
> I wish modify COPY command for support of CSV files (dump/load files in
> CSV format).
> I think this option is very important from import data from spreedsheet
> as OpenOffice/calc or M$/excel.
> I have found this task in TODO list, also.

A lot of work has already been done on this. You should read through
the archives. I think most of the discussion was roughly a month ago.


From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY command - CSV files
Date: 2004-05-06 01:24:38
Message-ID: 409993D6.8010203@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I believe this has already been implemented in CVS...

Chris

Umberto Zappi wrote:

> I wish modify COPY command for support of CSV files (dump/load files in
> CSV format).
> I think this option is very important from import data from spreedsheet
> as OpenOffice/calc or M$/excel.
> I have found this task in TODO list, also.


From: Umberto Zappi <uzappi(at)inwind(dot)it>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY command - CSV files
Date: 2004-05-06 22:31:51
Message-ID: 409ABCD7.9020404@inwind.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thanks to everybody has reply to my email.
Stop immediatly my work in progress.

Some days ago I've downloaded version 7.4.3 of postgresql and I've begin
to work over without know other jobs of other developers :-o

Bye
Umberto

Umberto Zappi wrote:

> I wish modify COPY command for support of CSV files (dump/load files in
> CSV format).
> I think this option is very important from import data from spreedsheet
> as OpenOffice/calc or M$/excel.
> I have found this task in TODO list, also.
>
> [...]
>
>


From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Umberto Zappi <uzappi(at)inwind(dot)it>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY command - CSV files
Date: 2004-05-06 23:59:56
Message-ID: 20040506235956.GI32667@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, May 07, 2004 at 12:31:51AM +0200, Umberto Zappi wrote:
> Thanks to everybody has reply to my email.
> Stop immediatly my work in progress.
>
> Some days ago I've downloaded version 7.4.3 of postgresql and I've begin
> to work over without know other jobs of other developers :-o

You should really get the CVS code if you want to hack on Postgres ...
there are a lot of changes since 7.4.3.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Jason Tesser: You might not have understood me or I am not understanding you.
Paul Thomas: It feels like we're 2 people divided by a common language...


From: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>
To: Umberto Zappi <uzappi(at)inwind(dot)it>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY command - CSV files
Date: 2004-05-07 01:40:30
Message-ID: 409AE90E.4060805@familyhealth.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Umberto,

If you are interested in doing any development work on PostgreSQL, you
_really_ need to work from the CVS version :)

Chris

Umberto Zappi wrote:

> Thanks to everybody has reply to my email.
> Stop immediatly my work in progress.
>
> Some days ago I've downloaded version 7.4.3 of postgresql and I've begin
> to work over without know other jobs of other developers :-o
>
> Bye
> Umberto
>
>
> Umberto Zappi wrote:
>
>> I wish modify COPY command for support of CSV files (dump/load files in
>> CSV format).
>> I think this option is very important from import data from spreedsheet
>> as OpenOffice/calc or M$/excel.
>> I have found this task in TODO list, also.
>>
>> [...]
>>
>>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster


From: Gaetano Mendola <mendola(at)bigfoot(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY command - CSV files
Date: 2004-05-07 13:09:58
Message-ID: c7g1ri$ag3$1@floppy.pyrenet.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:

> On Fri, May 07, 2004 at 12:31:51AM +0200, Umberto Zappi wrote:
>
>>Thanks to everybody has reply to my email.
>>Stop immediatly my work in progress.
>>
>>Some days ago I've downloaded version 7.4.3 of postgresql and I've begin
>>to work over without know other jobs of other developers :-o
>
>
> You should really get the CVS code if you want to hack on Postgres ...
> there are a lot of changes since 7.4.3.

7.4.3 is not out yet, even I don't find the TAG on CVS.

Regards
Gaetano Mendola


From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Gaetano Mendola <mendola(at)bigfoot(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY command - CSV files
Date: 2004-05-07 18:34:25
Message-ID: 20040507183425.GD2681@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, May 07, 2004 at 03:09:58PM +0200, Gaetano Mendola wrote:
> Alvaro Herrera wrote:
>
> >On Fri, May 07, 2004 at 12:31:51AM +0200, Umberto Zappi wrote:
> >
> >>Thanks to everybody has reply to my email.
> >>Stop immediatly my work in progress.
> >>
> >>Some days ago I've downloaded version 7.4.3 of postgresql and I've begin
> >>to work over without know other jobs of other developers :-o
> >
> >You should really get the CVS code if you want to hack on Postgres ...
> >there are a lot of changes since 7.4.3.
>
> 7.4.3 is not out yet, even I don't find the TAG on CVS.

Duh, isn't it? I haven't been paying attention to releases :-) But I
meant what's the current CVS tip for the 7.4 branch. Anyway there's a
lot of changes from there to the current CVS HEAD tip.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Aprender sin pensar es inĂștil; pensar sin aprender, peligroso" (Confucio)