Import csv

Поиск
Список
Период
Сортировка
Искать

Import csv

От:
Patrick Nelson <pnelson@neatech.com>
Дата:
I'm away from my PostgreSQL book (me SQL bible) and I'm faced with importing
csv (comma separated vales) file where I had setup all my scripts to tsv
(tab separated vales).  Yes I can use an editor, as such and change the
commas, but that's not the question.

How do I take a basic csv file and insert it into my table (named
dwnldstockanal)?  Just feel that this is something that I should know, but
me scratches me head.

Re: Import csv

От:
terry@greatgulfhomes.com
Дата:
devtest2=# \h copy
Command:     COPY
Description: copy data between files and tables
Syntax:
COPY [ BINARY ] table [ WITH OIDS ]
    FROM { 'filename' | stdin }
    [ [USING] DELIMITERS 'delimiter' ]
    [ WITH NULL AS 'null string' ]
COPY [ BINARY ] table [ WITH OIDS ]
    TO { 'filename' | stdout }
    [ [USING] DELIMITERS 'delimiter' ]
    [ WITH NULL AS 'null string' ]

Hence

COPY t1 FROM '' USING DELIMITERS ',';

Terry Fielder
Network Engineer
Great Gulf Homes / Ashton Woods Homes 
terry@greatgulfhomes.com

> -----Original Message-----
> From: pgsql-general-owner@postgresql.org
> [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Patrick Nelson
> Sent: Friday, July 26, 2002 1:45 PM
> To: PostgreSQL List (E-mail)
> Subject: [GENERAL] Import csv
> 
> 
> I'm away from my PostgreSQL book (me SQL bible) and I'm faced 
> with importing
> csv (comma separated vales) file where I had setup all my 
> scripts to tsv
> (tab separated vales).  Yes I can use an editor, as such and 
> change the
> commas, but that's not the question.
> 
> How do I take a basic csv file and insert it into my table (named
> dwnldstockanal)?  Just feel that this is something that I 
> should know, but
> me scratches me head.
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to 
> majordomo@postgresql.org)
> 

Re: Import csv

От:
Patrick Nelson <pnelson@neatech.com>
Дата:
terry@greatgulfhomes.com wrote:
----------------->>>>
devtest2=# \h copy
Command:     COPY
Description: copy data between files and tables
Syntax:
COPY [ BINARY ] table [ WITH OIDS ]
    FROM { 'filename' | stdin }
    [ [USING] DELIMITERS 'delimiter' ]
    [ WITH NULL AS 'null string' ]
COPY [ BINARY ] table [ WITH OIDS ]
    TO { 'filename' | stdout }
    [ [USING] DELIMITERS 'delimiter' ]
    [ WITH NULL AS 'null string' ]

Hence

COPY t1 FROM '' USING DELIMITERS ',';
----------------->>>>

Didn't even think of the psql \h copy... DOH!  Feel like a tard!  Anyway
thanks!  
FAQ