Re: importing a messy text file

Поиск
Список
Период
Сортировка
От Rob Sargentg
Тема Re: importing a messy text file
Дата
Msg-id 5360F855.9090305@gmail.com
обсуждение исходный текст
Ответ на Re: importing a messy text file  (Willy-Bas Loos <willybas@gmail.com>)
Список pgsql-general
On 04/30/2014 03:50 AM, Willy-Bas Loos wrote:
On Wed, Apr 30, 2014 at 11:06 AM, Rémi Cura <remi.cura@gmail.com> wrote:
with latest version 9.3 you can use a copy from with a programm as argument.
You can use the unix | pipe for most of the stuff.

If you have an older version you can use the mkfifo command to "trick" postgres into believing he will copy from a file.


Hi, you're right i can see the new feature in the docs.
But since i am working from the (bash) command line already, i don't see any use for this.
I already pass the data like this:
cat <file> |psql -c "copy <table> from stdin NULL ''" <db> > <file>.log 2>&1

It's especially handy if you want to stay in sql(transaction), i gues.

Cheers,

--
Willy-Bas Loos
Unless you know this is the only problem (extra/missing tab) I would triage the file with a scripting language. One favourite check is
awk '{a[NF]++}END{print "Field count: Record count";for (i in a){printf "%11d : %d", i, a[i]}}
If you only have the tab problem you will get two lines of output with field count = N, N-1.  Take care in setting the field separator.

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

Предыдущее
От: Michael Bostock
Дата:
Сообщение: Ingres to Postgres migration
Следующее
От: Jeff Johnston
Дата:
Сообщение: Re: Ingres to Postgres migration