Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id DF65B64FD14 for ; Wed, 10 Sep 2008 11:39:14 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 82677-10 for ; Wed, 10 Sep 2008 11:39:04 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from QMTA01.westchester.pa.mail.comcast.net (qmta01.westchester.pa.mail.comcast.net [76.96.62.16]) by postgresql.org (Postfix) with ESMTP id 44DFF64FCFD for ; Wed, 10 Sep 2008 11:39:02 -0300 (ADT) Received: from OMTA14.westchester.pa.mail.comcast.net ([76.96.62.60]) by QMTA01.westchester.pa.mail.comcast.net with comcast id D1q81a0091HzFnQ512eynR; Wed, 10 Sep 2008 14:38:58 +0000 Received: from tucker.local ([67.160.97.168]) by OMTA14.westchester.pa.mail.comcast.net with comcast id D2ex1a00M3dyZyT3a2exjj; Wed, 10 Sep 2008 14:38:58 +0000 X-Authority-Analysis: v=1.0 c=1 a=Qh6abZ5BlLEA:10 a=NWgspPMewLoA:10 a=WKIG8-Dg5G5hp8V4xDoA:9 a=7Yg9HkgLcESnugMSL6MA:7 a=dkw1dZ-3IGMG7twYTRmZB6SoC5sA:4 a=si9q_4b84H0A:10 a=LY0hPdMaydYA:10 From: Adrian Klaver To: pgsql-general@postgresql.org Subject: Re: [GENERAL] FW: How to upload data to postgres Date: Wed, 10 Sep 2008 07:38:56 -0700 User-Agent: KMail/1.9.10 Cc: "Markova, Nina" , pgsql-admin@postgresql.org References: <6D8C7E015447D0428D80E9DBABA06A1E03F4AA5C@S0-OTT-X2.nrn.nrcan.gc.ca> <200809091943.13745.aklaver@comcast.net> <6D8C7E015447D0428D80E9DBABA06A1E03F4AB76@S0-OTT-X2.nrn.nrcan.gc.ca> In-Reply-To: <6D8C7E015447D0428D80E9DBABA06A1E03F4AB76@S0-OTT-X2.nrn.nrcan.gc.ca> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200809100738.57156.aklaver@comcast.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200809/76 X-Sequence-Number: 30169 On Wednesday 10 September 2008 7:14:50 am Markova, Nina wrote: > Thanks Adrian. > > I have read the Postgres 'copy' - the problem is that Postgres doesn't > understand Ingres format. This is I think where the failure comes from. > If I don't find a tool, I have to write scripts to convert data to > something postgres understand. > > In the Ingres file with data for each varchar field, before the field is > the real size : > > 48070 820010601 820030210 41.890 > -80.811 0.000 1U > 3A16 819871030 0 47.471 -70.006 > 0.015 1R 0 > > In the example above: > 3A16 - means for varchar(5) field there are only characters, i.e. A16 > 48070 - means for varchar(5) field there are only 4 characters, i.e. > 8070 > 819871030 - 8 characters, i.e. 19871030 That would be the problem. The COPY from Postgres does not understand the metadata associated with the field data and would try to insert the complete string. I can see three options: 1) As has been suggested in another other post, export the Ingres data as data only CSV i.e 'A16' not '3A16' 2) Your suggestion of cleaning up data via a script. 3) Create holding table in Postgres that has varchar() fields (varchar with no length specified) and import into and then do your data cleanup before moving over to final table. > > When I created the same table in Postgres, inserted some test data and > later copied it to a file, this is how it looks like: > > A16 19871030 47.471 -70.006 0.015 R > KLNO 19801028 47.473 -70.006 0.016 R > MLNO 19801028 19990101 47.413 -70.006 0.016 R > > Column | Type | Modifiers > > -------------+------------------------+--------------------------------- > ------- > sta | character varying(5) | not null > ondate | character varying(8) | not null > offdate | character varying(8) | not null > lat | double precision | not null > lon | double precision | not null > elev | double precision | not null default 0 > regist_code | character(1) | not null default ' '::bpchar > > > Nina > -- Adrian Klaver aklaver@comcast.net