From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
---|---|
To: | Matthias Apitz <guru(at)unixarea(dot)de> |
Cc: | Postgres general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Two small questions re/ COPY CSV data into table |
Date: | 2019-06-04 10:32:45 |
Message-ID: | 877ea1aby6.fsf@news-spur.riddles.org.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>>>>> "Matthias" == Matthias Apitz <guru(at)unixarea(dot)de> writes:
Matthias> ... WITH DELIMITER '|', FORMAT CSV ;
I think you misread the docs; the new-style syntax would be
COPY ... WITH (DELIMITER '|', FORMAT CSV);
where the parens are not optional. The old-style syntax with no parens
after WITH is what you were using before.
Matthias> 2. The CSV export is done by some Sybase tool which escapes
Matthias> the delimiter as '\|', i.e. putting a backslash before the
Matthias> delimiter. I found no way that COPY understands this
Matthias> excaping. Any ideas?
That sounds like the file is not actually a CSV - why do you think it
is?
PG accepts two formats (actually 3 if you count binary format which is
rarely used):
TEXT: records are delimited by newlines, columns are delimited by a
delimiter character (default tab), there are no quotation marks, any
newline, backslash, or delimiter in the data must be escaped as a
backslash-sequence (e.g. \n or \012)
CSV: columns may be quoted (in which case delimiters and newlines inside
them are ignored), records are delimited by newlines _outside_ quoted
fields, there are no backslash-sequences or escapes outside of quoted
fields, quote characters inside quoted fields are doubled (though
there's an option to change this).
PG follows the CSV spec at https://www.ietf.org/rfc/rfc4180.txt fairly
closely.
--
Andrew (irc:RhodiumToad)
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Gierth | 2019-06-04 10:38:45 | Re: Research on ?? operators |
Previous Message | Matthias Apitz | 2019-06-04 10:02:47 | Two small questions re/ COPY CSV data into table |