Re: request for help with COPY syntax

Поиск
Список
Период
Сортировка
От Chuck D.
Тема Re: request for help with COPY syntax
Дата
Msg-id 200710261029.56284.pgsql-list@nullmx.com
обсуждение исходный текст
Ответ на Re: request for help with COPY syntax  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
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



В списке pgsql-sql по дате отправления:

Предыдущее
От: "Jonah H. Harris"
Дата:
Сообщение: Re: JOINing based on whether an IP address is contained within a CIDR range?
Следующее
От: Thomas Kellerer
Дата:
Сообщение: Removing whitespace using regexp_replace