Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 3C2C19FC470 for ; Fri, 26 Oct 2007 01:26:31 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 02164-08 for ; Fri, 26 Oct 2007 01:26:13 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from k2smtpout02-01.prod.mesa1.secureserver.net (k2smtpout02-01.prod.mesa1.secureserver.net [64.202.189.90]) by postgresql.org (Postfix) with SMTP id BAE9D9FC437 for ; Fri, 26 Oct 2007 01:26:24 -0300 (ADT) Received: (qmail 13266 invoked from network); 26 Oct 2007 04:26:22 -0000 Received: from unknown (HELO mail.servantwebhosting.com) (68.178.159.82) by k2smtpout02-01.prod.mesa1.secureserver.net (64.202.189.90) with ESMTP; 26 Oct 2007 04:26:22 -0000 Received: (qmail 30587 invoked from network); 25 Oct 2007 21:26:21 -0700 Received: from s010600e0296eec95.mj.shawcable.net (HELO shach) (rob@nullmx.com@70.64.195.140) by mail.servantwebhosting.com with SMTP; 25 Oct 2007 21:26:21 -0700 From: "Chuck D." Reply-To: pgsql-list@nullmx.com To: pgsql-sql@postgresql.org Subject: Re: request for help with COPY syntax Date: Thu, 25 Oct 2007 22:26:17 -0600 User-Agent: KMail/1.9.6 References: <043e01c8174c$61157a50$8f01010a@iptel.com.ar> <200710252016.16121.pgsql-list@nullmx.com> <2080.1193368930@sss.pgh.pa.us> In-Reply-To: <2080.1193368930@sss.pgh.pa.us> MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200710252226.17852.pgsql-list@nullmx.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/130 X-Sequence-Number: 29502 On October 25, 2007 09:22:10 pm you wrote: > Did the sed actually do anything? (Hint: the file size of > geonames_fixed.txt would be larger than geonames.txt if it did. > Or you could diff the two files to confirm that something sensible > happened.) > > I suspect that your shell may be fouling things up here. You may need > to prepare this command as a one-line shell script, using an editor that > doesn't barf on bare carriage returns ... > > regards, tom lane OK, here's a bit more info after testing the sed on a bash line and in a /bin/sh script edited with vi. One of the troubling rows from the original file looks like this. This is a couple fields, not the whole row. cat -A short.txt ^IJishishan Bonanzu Dongxiangzu Salarzu Zizhixian^M$ Jishishan Bonanzu Dongxiangzu Salarzu Zizhixian^M$ Jishishan Bonanzu Dongxiangzu Salarzu Zizhixian^M$ ^I2007-07-06$ Here's the shell script: /bin/sed 's/^M/\\r/' < short.txt > short.out And the result: ^IJishishan Bonanzu Dongxiangzu Salarzu Zizhixian\r$ Jishishan Bonanzu Dongxiangzu Salarzu Zizhixian\r$ Jishishan Bonanzu Dongxiangzu Salarzu Zizhixian\r$ ^I2007-07-06$ Of course it sees the \r$ as the end of line and fails with: ERROR: missing data for column "full_name" Does that help diagnose?