Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id F398A9FA5DA for ; Fri, 26 Oct 2007 13:30:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 58825-05 for ; Fri, 26 Oct 2007 13:30:22 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from k2smtpout04-02.prod.mesa1.secureserver.net (k2smtpout04-02.prod.mesa1.secureserver.net [64.202.189.173]) by postgresql.org (Postfix) with SMTP id F05AD9FA546 for ; Fri, 26 Oct 2007 13:30:21 -0300 (ADT) Received: (qmail 16724 invoked from network); 26 Oct 2007 16:30:07 -0000 Received: from unknown (HELO mail.servantwebhosting.com) (68.178.159.82) by k2smtpout04-02.prod.mesa1.secureserver.net (64.202.189.173) with ESMTP; 26 Oct 2007 16:30:06 -0000 Received: (qmail 22436 invoked from network); 26 Oct 2007 09:30:05 -0700 Received: from s010600e0296eec95.mj.shawcable.net (HELO shach) (rob@nullmx.com@70.64.195.140) by mail.servantwebhosting.com with SMTP; 26 Oct 2007 09:30:05 -0700 From: "Chuck D." Reply-To: pgsql-list@nullmx.com To: pgsql-sql@postgresql.org Subject: Re: request for help with COPY syntax Date: Fri, 26 Oct 2007 10:29:56 -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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200710261029.56284.pgsql-list@nullmx.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/134 X-Sequence-Number: 29506 On October 25, 2007 09:22:10 pm Tom Lane 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 ... Can I ask this, what is the objective here? I have a field with ^M$ in it (shows as CR/LF in text editor). The objective should be to replace the CR/LF with just a CR shouldn't it? Or is the objective to replace the CR/LF with a literal \r? I'm a bit confused by the output of COPY that says to use "\r". Looking at other data in my database (user message) I'd have to say it needs to be replaced with a literal \r correct? If that is the case, the sed script doesn't work because it is only replacing the CR and still leaves the LF which terminates a line. I found a little perl to do the job of replacing the CR/LF with a literal \r perl -p -e 's/\r\n/\\r/g' < cities.txt > cities_fixed.txt