public inbox for [email protected]  
help / color / mirror / Atom feed
From: Andrei M. Eichler <[email protected]>
To: Kevin Grittner <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: COPY options
Date: Fri, 29 Apr 2016 12:31:37 -0300
Message-ID: <CABS=F1+hjzqLgkx23p6RqPkyim_c2GOdMdsBZgGj27qAwwEyxw@mail.gmail.com> (raw)
In-Reply-To: <CACjxUsM_4O40y_bMjh3UAMmY1q3dTqecJzqRBJFzp-wkZcYCGg@mail.gmail.com>
References: <CABS=F1+aHKpE9Z2CwnffwCOxRKn9pFuYBsoAkHCL82YLm2q3eg@mail.gmail.com>
	<CACjxUsM_4O40y_bMjh3UAMmY1q3dTqecJzqRBJFzp-wkZcYCGg@mail.gmail.com>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-docs>

Hi, thanks for the wiki link.

I'm using Postgrees 9.5.2, running on Debian 8.4

I have a csv file with all columns quoted, even null values.

Following the documentation, I wrote this COPY FROM command:

COPY test_copy FROM '/mnt/disk1/files/test_file.csv' with csv header
delimiter ';' force_null date_column, date_column2, date_column3,
date_column4, date_column5 encoding 'latin1';

And received this error message:

ERROR:  syntax error at or near "force_null"
LINE 1: ...test_file.csv' with csv header delimiter ';' force_null...


To fix the error, I had to replace the "_" to " ", so "force_null" becomes
"force null" :

COPY test_copy FROM '/mnt/disk1/files/test_file.csv' with csv header
delimiter ';' force null date_column, date_column2, date_column3,
date_column4, date_column5 encoding 'latin1';

COPY 99999

In the docs (http://www.postgresql.org/docs/current/static/sql-copy.html)
the "FORCE" options are written with "_" but the correct name is with " "



2016-04-28 17:27 GMT-03:00 Kevin Grittner <[email protected]>:

> On Thu, Apr 28, 2016 at 11:58 AM, Andrei M. Eichler
> <[email protected]> wrote:
>
> > when one tries to use it as it is from the docs, one gets the following
> > results:
> > ERROR:  syntax error at or near "force_null"
>
> Works for me.
>
> Please copy/paste the actual command and the actual, complete error
> message.
>
> https://wiki.postgresql.org/wiki/Guide_to_reporting_problems
>
> --
> Kevin Grittner
> EDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>


view thread (7+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: COPY options
  In-Reply-To: <CABS=F1+hjzqLgkx23p6RqPkyim_c2GOdMdsBZgGj27qAwwEyxw@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox