pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6017: COPY from CSV file, WITH CSV HEADER fields order not respected
2+ messages / 2 participants
[nested] [flat]

* BUG #6017: COPY from CSV file, WITH CSV HEADER fields order not respected
@ 2011-05-09 18:07  pedro mg <pedro@tquadrado.com>
  0 siblings, 1 reply; 2+ messages in thread

From: pedro mg @ 2011-05-09 18:07 UTC (permalink / raw)
  To: pgsql-bugs


The following bug has been logged online:

Bug reference:      6017
Logged by:          pedro mg
Email address:      pedro@tquadrado.com
PostgreSQL version: 8.4.8
Operating system:   Ubuntu Linux 10.10
Description:        COPY from CSV file, WITH CSV HEADER fields order not
respected
Details: 

Documentation says HEADER is discarded for reads. When uploading millions of
records from other legacy databases, would be an awesome addition to have
Header fields order not discarded for reads.

-Have a table: \d test1

 key    | integer               | not null default
nextval('teste1_key_seq'::regclass)
 c1     | character varying(10) | 
 c2     | double precision      | 
Indexes:
    "teste1_pkey" PRIMARY KEY, btree (key)

- Have a CSV file, /tmp/test1.csv with an HEADER first line with the
following order (note:different from the table):

key,c2,c1
1,1,"Kg"
2,2,"g"
3,3,"mg"
4,4,"µg"
5,11,"l"
6,12,"ml"
7,13,"µl"

- Issue a COPY command:

# COPY test1 FROM '/tmp/test1.csv' WITH CSV HEADER

- Returns:

ERROR:  invalid input syntax for type double precision: "Kg"
CONTEXT:  COPY teste1, line 2, column c2: "Kg"



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #6017: COPY from CSV file, WITH CSV HEADER fields order not respected
@ 2011-05-10 00:19  Euler Taveira de Oliveira <euler@timbira.com>
  parent: pedro mg <pedro@tquadrado.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Euler Taveira de Oliveira @ 2011-05-10 00:19 UTC (permalink / raw)
  To: pedro mg <pedro@tquadrado.com>; +Cc: pgsql-bugs

Em 09-05-2011 15:07, pedro mg escreveu:
> # COPY test1 FROM '/tmp/test1.csv' WITH CSV HEADER
>
Why don't you specify the columns?

COPY test1 (key, c2, c1) FROM '/tmp/test1.csv' WITH CSV HEADER


-- 
   Euler Taveira de Oliveira - Timbira       http://www.timbira.com.br/
   PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2011-05-10 00:19 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-05-09 18:07 BUG #6017: COPY from CSV file, WITH CSV HEADER fields order not respected pedro mg <pedro@tquadrado.com>
2011-05-10 00:19 ` Euler Taveira de Oliveira <euler@timbira.com>

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