syntax of \copy

Поиск
Список
Период
Сортировка
От richard terry
Тема syntax of \copy
Дата
Msg-id 200910080839.38342.rterry@pacific.net.au
обсуждение исходный текст
Ответы Re: syntax of \copy  (Bruce Momjian <bruce@momjian.us>)
Список pgsql-novice
Hi,

I'm trying at the command line (linux) to import a csv file with this sort of
format

"A", "name","etc","1"

If I simply eliminate the quotes in a text editor, replace the commas with |
then this snytax works

If I have a file say import.sql containing this line:

\copy schema.tablename from '/tmp/myfile.CSV' delimiter ','  NULL AS ''

and at the command line type:

psql mydb -f import.sql

then it works fine.

But I want to be able to just use the file 'as is', ie with its quotes so I
don't have to manually do a global replace.

I've pored over the docs but always find it difficult to interpret them, it
mentions a CSV mode but I can't figure out how to use it.

The internet is equally unrewarding as whilst there are trillions of
references as to \copy etc, no-one seems to give a concrete example when
importing a csv file that has been exported with quotes,

Any  help appreciated

Richard

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

Предыдущее
От: Professor Flávio Brito
Дата:
Сообщение: Re: /Var Partition Full - How can a change PGDATA?
Следующее
От: keshav upadhyaya
Дата:
Сообщение: Regarding mulitple rows insert in one shot using ADO .net connected to postgres