X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D8FBC32AD90 for ; Tue, 12 Oct 2004 14:56:26 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 18638-09 for ; Tue, 12 Oct 2004 13:56:16 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5FE6A32A6A5 for ; Tue, 12 Oct 2004 14:56:17 +0100 (BST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id i9CDuF7l001764; Tue, 12 Oct 2004 09:56:16 -0400 (EDT) To: Theo Galanakis Cc: pgsql-sql@postgresql.org Subject: Re: Export tab delimited from mysql to postgres. In-reply-to: <82E30406384FFB44AFD1012BAB230B5505F40D43@shiva.au.lpint.net> References: <82E30406384FFB44AFD1012BAB230B5505F40D43@shiva.au.lpint.net> Comments: In-reply-to Theo Galanakis message dated "Tue, 12 Oct 2004 15:33:46 +1000" Date: Tue, 12 Oct 2004 09:56:15 -0400 Message-ID: <1763.1097589375@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/85 X-Sequence-Number: 19188 Theo Galanakis writes: > As you can see row 2 has a value that holds a CR value which ends up > wrapping around onto the third line. Postgres copy command does not like > this and mysql is unable to replace the value with another type of > delimiter, like a \r. > So I gather I have to some how manually replace the carriage return with > something postgres understand \r... > columnA columnB > 1 What a day! > 2 What a week it has \r been! > 3 What the! > How do I do this without getting a text file that looks like this > 1 What a day! \r\n2 What a week it has \r been!\r\n3 > What the!\r\n Looks like a simple sed problem to me: cat myfile | sed 's/\r$//' | sed 's/\r/\\r/g' >newfile (Most likely you can do both steps in one sed process, but this is easy to follow.) This assumes that you only have newlines (\n) at the real ends of lines, else you need to think harder about how to tell the difference between data and formatting. regards, tom lane