COPY command

Поиск
Список
Период
Сортировка
Искать

COPY command

От:
azwa@nc.com.my
Дата:

Hi,


  i try to load a file into temporary table but it gives me an error . do u have any idea/solutions ??  the command that i've running 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

FYI, my file was in comma delimiter type (csv) . My table structure as following :

    dwnc-# \dbiosadm.custdo_temp
         Table "biosadm.custdo_temp"
  Column  |         Type          | Modifiers
----------+-----------------------+-----------
 dono     | character varying(13) |
 dodate   | date                  |
 custname | character varying(70) |
 custlo   | character varying(40) |
 attnto   | character varying(80) |


Please guide me . thanks

Re: COPY command

От:
"Gregory S. Williamson" <gsw@globexplorer.com>
Дата:
This sounds as if the last character in each line might be a delimiter (a ",") which is standard for data unloaded from some sources; if this is the case try removing it and your data should load. Or you may have a comma in a character field and that is throwing off the count for the line in question ?

HTH,

Greg Williamson
DBA
GlobeXplorer LLC

-----Original Message-----
From:	azwa@nc.com.my [mailto:azwa@nc.com.my]
Sent:	Tue 1/6/2004 10:19 PM
To:	pgsql-sql@postgresql.org
Cc:	
Subject:	[SQL] COPY command

Hi,

 i try to load a file into temporary table but it gives me an error . do 
u have any idea/solutions ??  the command that i've running 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

FYI, my file was in comma delimiter type (csv) . My table structure as 
following :
   dwnc-# \dbiosadm.custdo_temp        Table "biosadm.custdo_temp" Column  |         Type          | Modifiers
----------+-----------------------+-----------dono     | character varying(13) |dodate   | date                  |custname | character varying(70) |custlo   | character varying(40) |attnto   | character varying(80) |


Please guide me . thanks



Re: COPY command

От:
azwa@nc.com.my
Дата:
Hi ,


yes now i can do the copy after replace comma delimiter with tab delimiter which is default copy with delimiter . btw  i've another
question : how do we run the COPY command from file which has several null columns in each field.  
thanks.

example :

   dwnc=# copy biosadm.custinv_temp
dwnc-# from '/home/bios/customer_data/CustomerInvoice_5Dec03_tab.txt' ;
ERROR:  copy: line 1, Missing data for column "subsidiary"  


p/s: my subsidiary column has several null data.


"Gregory S. Williamson" <gsw@globexplorer.com>

07:06 PM PST Yesterday


        To:        <azwa@nc.com.my>, <pgsql-sql@postgresql.org>
        cc:        
        Subject:        RE: [SQL] COPY command



This sounds as if the last character in each line might be a delimiter (a ",") which is standard for data unloaded from some sources; if this is the case try removing it and your data should load. Or you may have a comma in a character field and that is throwing off the count for the line in question ?

HTH,

Greg Williamson
DBA
GlobeXplorer LLC

-----Original Message-----
From:                 azwa@nc.com.my [mailto:azwa@nc.com.my]
Sent:                 Tue 1/6/2004 10:19 PM
To:                 pgsql-sql@postgresql.org
Cc:                
Subject:                 [SQL] COPY command

Hi,


 i try to load a file into temporary table but it gives me an error . do
u have any idea/solutions ??  the command that i've running 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

FYI, my file was in comma delimiter type (csv) . My table structure as
following :

   dwnc-# \dbiosadm.custdo_temp
        Table "biosadm.custdo_temp"
 Column  |         Type          | Modifiers
----------+-----------------------+-----------
dono     | character varying(13) |
dodate   | date                  |
custname | character varying(70) |
custlo   | character varying(40) |
attnto   | character varying(80) |


Please guide me . thanks



Re: COPY command

От:
Michael Glaesemann <grzm@myrealbox.com>
Дата:

On Jan 9, 2004, at 1:11 PM, azwa@nc.com.my wrote:
> how do we run the COPY command from file which has several null
> columns in each field.  
> thanks.
>
> example :
>
>    dwnc=# copy biosadm.custinv_temp
> dwnc-# from '/home/bios/customer_data/CustomerInvoice_5Dec03_tab.txt' ;
> ERROR:  copy: line 1, Missing data for column "subsidiary"  

Just like you specify the delimiter, you need to specify the value for 
NULL. For example, if your *.txt file has a line with a "missing" value 
(such as the space between 'bar' and 'foofoo')

foo	bar		foofoo	barbar

I usually use 'NULL' as NULL, so the line would be

foo	bar	NULL	foofoo	barbar

then use the COPY command with NULL AS 'NULL'

Check out the following link for detailed info on the COPY command:


HTH

Michael Glaesemann
grzm myrealbox com


FAQ