Re: Error on import - Mailing list pgsql-general

From Medi Montaseri
Subject Re: Error on import
Date
Msg-id 3DB8D3B4.9040406@intransa.com
Whole thread Raw
In response to Re: Error on import  ("John" <johnp@totcon.com>)
List pgsql-general
here is even a smaller version of

perl -i -pe 's/\r\n/\n/' filename

which says...
-i do the modification in place
-p read and process every line/record of the file
-e run the following expressiion
's/\r\n/\n/'   substitude '\r\n' with '\n'

Then create an alias like

alias dos2unix="perl -i -pe 's/\r\n/\n/' "

And then say

dos2unix myfile

And here is unix2dos
alias unix2dos="perl -i -pe 's/\n/\r\n/' "

Yes I know Solaris has dos2unix(1) and unix2dos(1), I'm just having a
little fun...
By the way these work on both Unix and NT environment, find a substitude
for aliases
on NT.

John wrote:

>Thanks Tom.. I had a buddy who works with perl give me a little help
>since I couldn't get vim to see the \r.. the following one liner got me
>where I needed to be. Thanks again.
>
>cat origfile|perl -e 'while (<>){$_ =~ s/\r//g;print $_;}' > prepfile
>
>-----Original Message-----
>I think you've got DOS-style newlines (\r\n) in your data file.
>Get rid of the carriage return characters (\r) and you'll be set.
>
>            regards, tom lane
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>




pgsql-general by date:

Previous
From: "John"
Date:
Subject: Re: Error on import
Next
From: Christian Traber
Date:
Subject: Re: number of affected rows in pgtcl