Re: import csv file into table

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Jude DaShiell <jdashiel(at)panix(dot)com>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: import csv file into table
Date: 2015-06-12 16:52:17
Message-ID: CAKFQuwaoRsfOuBxjnKd4ott_i7qjpbFnZSCtTiM+V2XTOwtMfg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, Jun 12, 2015 at 11:38 AM, Jude DaShiell <jdashiel(at)panix(dot)com> wrote:

> ​[...]
> and ' for beginning and end of records
> ​[...]
>

​This is the problem. You need to remove the first and last single-quote
and ensure that fields do not contain embedded commas. COPY will work if
those two things hold true. Embedded commas and field quoting are the main
difficulties with using comma-separated format.​

COPY is efficient but it expects you to provide clean data to it. You need
to fix those items externally to PostgreSQL.

I have not used it myself but you might evaluate pgloader.
http://pgloader.io/

David J.

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Jude DaShiell 2015-06-13 11:00:06 Re: import csv file into table
Previous Message learnnewtech2015 2015-06-12 15:50:53 PostgreSQL GUI Tool with GIT repository integration