| From: | Greg Smith <greg(at)2ndquadrant(dot)com> | 
|---|---|
| To: | Lou Picciano <loupicciano(at)comcast(dot)net> | 
| Cc: | pgsql-admin <pgsql-admin(at)postgresql(dot)org> | 
| Subject: | Re: How To: LARGE html text or csv file COPY FROM? | 
| Date: | 2010-09-16 01:26:36 | 
| Message-ID: | 4C91724C.4040802@2ndquadrant.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-admin | 
Lou Picciano wrote:p { margin: 0; }
> Both errors above make sense to me; COPY is running into either a cr 
> or a tab character in each case.
Even though they might seem very similar at first, text mode and CSV 
mode work very differently here.  To quote TFM at 
http://www.postgresql.org/docs/current/static/sql-copy.html , which 
covers all this if you dig into it enough:
"CSV mode will both recognize and produce CSV files with quoted values 
containing embedded carriage returns and line feeds. Thus the files are 
not strictly one line per table row like text-mode files."
So as long as the field is quoted, you can have a CR or tab in the middle.
In text mode:  "the following characters /must/ be preceded by a 
backslash if they appear as part of a column value: backslash itself, 
newline, carriage return, and the current delimiter character."  Text 
mode will therefore require escaping everything on that list.
So if this is close to being importable in CSV mode, you might just need 
to wrap the HTML field with a pair of quotes, and escape any quote 
characters that are inside of it.  Text mode is going to require a whole 
escaping run of all the reserved characters that are input.
-- 
Greg Smith, 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services and Support  www.2ndQuadrant.us
Author, "PostgreSQL 9.0 High Performance"    Pre-ordering at:
https://www.packtpub.com/postgresql-9-0-high-performance/book
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Anuj Pankaj | 2010-09-16 05:10:31 | Re: issue with Postgres uninstallation | 
| Previous Message | Kevin Grittner | 2010-09-15 18:26:17 | Re: can you change pg_hba.conf and restart the listener on the fly? |