| From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> | 
|---|---|
| To: | "E(dot) Matthew Finnin" <emf(dot)storage(at)gmail(dot)com> | 
| Cc: | pgsql-novice(at)postgresql(dot)org | 
| Subject: | Re: The COPY command and csv files | 
| Date: | 2006-04-13 22:29:22 | 
| Message-ID: | 200604132229.k3DMTMj11909@candle.pha.pa.us | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
E. Matthew Finnin wrote:
> **I apologize in advance if this is a familiar question, but I couldn't
> find an answer**
> 
> I am attempting to copy a csv file into a table, but no matter what I
> can think of I get  one of two errors.  I am using Postgresql 8.1.2.
> 
> 1.) Here is the first COPY command I gave:
>   COPY pwt61_oecd FROM stdin
>   WITH DELIMITER AS ','
>   CSV QUOTE AS ' " '
Should be '"', not ' " '.  In fact, DELIMITER and QUOTE are the
defaults, so there is no need to specify them.
>   NULL AS 'na'
>   ;
> 2.) Curious if I would get the same error, I attemtped to use the
> \copy command in psql, but this time I removed the column headers from
> the csv file:
> 
> \copy pwt61_oecd FROM '/home/.../data/pwt61_oecd2.csv' WITH DELIMITER
> AS ',' CSV QUOTE AS ' " ' NULL AS 'na'
> 
> And the error report:
>    ERROR: invalid input syntax for type numeric: "na"
>    CONTEXT: COPY pwt61_oecd, line 1, column cgnp: "na"
> 
Yep, same ' " ' problem.  We disallows multi-character delimiters in
current CVS, but you might not have the 8.1.X backpatch.
If you have continued problems, please send us the table schema and a
line that is failing and we can help you get it working.
-- 
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
| From | Date | Subject | |
|---|---|---|---|
| Next Message | operationsengineer1 | 2006-04-13 23:13:37 | Re: Colors/bold chars in a select? | 
| Previous Message | Ennio-Sr | 2006-04-13 22:13:24 | Re: Colors/bold chars in a select? |