pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feeddata loading
4+ messages / 3 participants
[nested] [flat]
* data loading
@ 2004-01-09 02:13 azwa@nc.com.my
0 siblings, 2 replies; 4+ messages in thread
From: azwa@nc.com.my @ 2004-01-09 02:13 UTC (permalink / raw)
To: pgsql-sql
Hi,
i try to load data from flat file (comma delimiter format) into
temporary table . i use COPY command as below:
dwnc=# copy biosadm.custdo_temp
dwnc-# from '/home/bios/customer_data/CustomerDO_new.CSV'
dwnc-# WITH DELIMITER ',' ;
ERROR: copy: line 141, Extra data after last expected column
do u have any idea what causes the above error ???or is there any command
can be used to load data as requested. tq
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: data loading
@ 2004-01-09 20:04 Richard Huxton <dev@archonet.com>
parent: azwa@nc.com.my
1 sibling, 1 reply; 4+ messages in thread
From: Richard Huxton @ 2004-01-09 20:04 UTC (permalink / raw)
To: azwa@nc.com.my; pgsql-sql
On Friday 09 January 2004 02:13, azwa@nc.com.my wrote:
> Hi,
>
>
> i try to load data from flat file (comma delimiter format) into
> temporary table . i use COPY command as below:
>
> dwnc=# copy biosadm.custdo_temp
> dwnc-# from '/home/bios/customer_data/CustomerDO_new.CSV'
> dwnc-# WITH DELIMITER ',' ;
>
> ERROR: copy: line 141, Extra data after last expected column
Does line 141 (or nearby) have a comma somewhere in its data? That would fool
the COPY into mis-counting the columns. See the COPY entry in the SQL Command
Reference chapter of the manuals - you'll want to escape any commas with a
backslash:
\,
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: data loading
@ 2004-01-09 20:06 Richard Huxton <dev@archonet.com>
parent: azwa@nc.com.my
1 sibling, 0 replies; 4+ messages in thread
From: Richard Huxton @ 2004-01-09 20:06 UTC (permalink / raw)
To: azwa@nc.com.my; pgsql-sql
On Friday 09 January 2004 02:13, azwa@nc.com.my wrote:
> Hi,
>
Just realised this question is also posted under COPY command. Ignore me.
--
Richard Huxton
Archonet Ltd
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: data loading
@ 2004-01-10 18:28 Jeff Eckermann <jeff_eckermann@yahoo.com>
parent: Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Eckermann @ 2004-01-10 18:28 UTC (permalink / raw)
To: azwa@nc.com.my; pgsql-sql
--- Richard Huxton <dev@archonet.com> wrote:
> On Friday 09 January 2004 02:13, azwa@nc.com.my
> wrote:
> > Hi,
> >
> >
> > i try to load data from flat file (comma
> delimiter format) into
> > temporary table . i use COPY command as below:
> >
> > dwnc=# copy biosadm.custdo_temp
> > dwnc-# from
> '/home/bios/customer_data/CustomerDO_new.CSV'
> > dwnc-# WITH DELIMITER ',' ;
> >
> > ERROR: copy: line 141, Extra data after last
> expected column
>
> Does line 141 (or nearby) have a comma somewhere in
> its data? That would fool
> the COPY into mis-counting the columns. See the COPY
> entry in the SQL Command
> Reference chapter of the manuals - you'll want to
> escape any commas with a
> backslash:
> \,
CSV deals with embedded commas by quoting the data
field that contains it. Applications that are aware
of this will know to ignore commas within quoted
strings. COPY is not smart enough to figure this out
(nor smart enough to strip off any quotes, which will
be imported as data). If you know for a fact that
your data contains no quotes, then you can get away
with the "with delimiters ','" trick. Otherwise, you
will need to preprocess your data through something
that will parse the CSV format, e.g. some Perl module.
Note that hand rolled solutions usually underestimate
the complexity of dealing with CSV data, and why
bother when others have already solved the problem for you.
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2004-01-10 18:28 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-01-09 02:13 data loading azwa@nc.com.my
2004-01-09 20:04 ` Richard Huxton <dev@archonet.com>
2004-01-10 18:28 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
2004-01-09 20:06 ` Richard Huxton <dev@archonet.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