Re: COPY formatting

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: tswan(at)idigx(dot)com
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Postgresql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: COPY formatting
Date: 2004-03-19 19:01:17
Message-ID: 200403191901.i2JJ1Hu20522@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thomas Swan wrote:
> > I have never seen such a beast, and if I had been asked off the cuff
> > would have said that it was probably illegal, except that I know of no
> > standard actually defining the format. Perhaps others (Joshua Drake or
> > Josh Berkus?) have wider experience. I think in any case we should
> > ignore those for now and handle the straightforward case.
> >
> > I *have* seen monstrosities like fields that do not begin with the quote
> > character but then break into a quote, e.g.:
> >
> > 1,2,a,123"abc""def",6,7,8
> >
>
> I have dealt with both, frequently. The CSV format allows you to begin a
> block of text with the quote. Newlines are included in that quoted space.
> If qoutes are included in the field then the quotes are double quotes to
> denote they are not part of the quoted space.
>
> Also, the following is valid.
>
> 1,2,,,"",,,""
>
> "" is empty.
>
> 1,2,3,"""",,,,"",
>
> The 4 quotes denote a single double quote.
>
> Writing simple CSV converts that just explode on commas and newlines miss
> these oddities.

OK, so for the separator, quote, and escape options:

separator is ,
quote is "
escape is "

so if the quote and escape are the same, then a double denotes a
single?

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2004-03-19 19:07:29 Re: COPY formatting
Previous Message Andrew Dunstan 2004-03-19 18:59:54 Re: COPY formatting