Re: Need help for import of text file

Поиск
Список
Период
Сортировка
От Peter Bex
Тема Re: Need help for import of text file
Дата
Msg-id 20121215211655.GM4254@frohike.homeunix.org
обсуждение исходный текст
Ответ на Need help for import of text file  (Andreas <maps.on@gmx.net>)
Ответы Re: Need help for import of text file
Список pgsql-general
On Sat, Dec 15, 2012 at 08:06:44PM +0100, Andreas wrote:
> Hi,
>
> Problem here is in the morning the first digit of the hour is shown as a
> blank so there are 2 blanks before the time so COPY misstakes this as an
> empty column and gets confused.
>
> Can someone point me in the direction of an COPY option I'm not aware
> of, or alternativly to some console tool that I can put in the batch
> before the import step and replace the 2 blanks with 1 blank.
>
> I use an OpenSuse server so some linux tool would do.

A simple sed(1) expression should do the trick:

sed -E 's/ +/ /g' old-file > new-file

GNU sed also allows in-place editing using -i, so you can avoid
writing it to a second file.  Some seds accept a different flag
to enable extended regexps.

Cheers,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                            -- Donald Knuth


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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Need help for import of text file
Следующее
От: Peter Bex
Дата:
Сообщение: Re: Need help for import of text file