Re: loading delimited files - Mailing list pgsql-general

From will trillich
Subject Re: loading delimited files
Date
Msg-id 20030121182859.GB4849@mail.serensoft.com
Whole thread Raw
In response to loading delimited files  ("Campano, Troy" <Troy.Campano@LibertyMutual.com>)
Responses Re: loading delimited files
List pgsql-general
On Mon, Jan 13, 2003 at 01:27:29PM -0500, Campano, Troy wrote:
> Are there docs on how to load delimited files into the database?

closer than you might think. "\h copy"!

    psql somedatabase

    somedatabase> \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' ]

\t (tab) is default field separator,
\n (newline) is default record separator,
\N is default for NULL

pick a small table in your current database and try

    psql> copy tinytable to stdout;

to see the format. note that ALL fields in the table are
exported, and should be included on the import, as well (in
field-definition order, from your create statements).

    psql> copy atable FROM '/this/file/here.tsv';

--
There are 10 kinds of people:
ones that get binary, and ones that don't.

will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

Looking for a firewall? Do you think smoothwall sucks? You're
probably right... Try the folks at http://clarkconnect.org/ !

pgsql-general by date:

Previous
From: Tom Jenkins
Date:
Subject: Re: PL/Python
Next
From: ahoward@fsl.noaa.gov (ara howard)
Date:
Subject: Re: postmaster.pid