CSV import

From: Oliver Vecernik <vecernik(at)aon(dot)at>
To: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: CSV import
Date: 2003-01-28 14:46:07
Message-ID: 3E3697AF.2030509@aon.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi again!

After investigating a little bit further my CSV import couldn't work
because of following reasons:

1. CSV files are delimited with CR/LF
2. text fields are surrounded by double quotes

Is there a direct way to import such files into PostgreSQL?

I would like to have something like MySQL provides:

LOAD DATA [LOW_PRIORITY | CONCURRENT] [LOCAL] INFILE 'file_name.txt'
[REPLACE | IGNORE]
INTO TABLE tbl_name
[FIELDS
[TERMINATED BY '\t']
[[OPTIONALLY] ENCLOSED BY '']
[ESCAPED BY '\\' ]
]
[LINES TERMINATED BY '\n']
[IGNORE number LINES]
[(col_name,...)]

Has anybody written such a function already?

Regards,
Oliver

--
VECERNIK Datenerfassungssysteme
A-2560 Hernstein, Hofkogelgasse 17
Tel.: +43 2633 47530, Fax: DW 50
http://members.aon.at/vecernik

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-01-28 15:28:26 Re: import error
Previous Message Oliver Vecernik 2003-01-28 14:08:37 Re: CR/LF conversion (was: import error)