Re: [GENERAL] import CSV file to a table

Поиск
Список
Период
Сортировка
От vinny
Тема Re: [GENERAL] import CSV file to a table
Дата
Msg-id 6bfaa830b0fca837623f6b48903dfdec@xs4all.nl
обсуждение исходный текст
Ответ на [GENERAL] import CSV file to a table  (Günce Kaya <guncekaya14@gmail.com>)
Ответы Re: [GENERAL] import CSV file to a table
Список pgsql-general
On 2017-03-08 10:13, Günce Kaya wrote:
> Hi all,
>
> I want to import content of CSV file to a table via bash script
> without creating temporary table and I also want to skip some columns
> in CSV file (for instance, CSV file has 12 column and main table has
> only 2 column, If possible I would use only 2 column in CSV file) Is
> there any way to do it?
>
> Regards,
>
> --
>
> Gunce Kaya

This is more a programming question than a database question, and there
are many possible solutions.
Do *not*, whatever you do, try to write your own piece of code to read
the CSV. There are lots of unexpected
ways that the CSV file can be slightly different from what you expect,
and figuring all those out is a waste of time.
The example of embedded comma's is just one way, there could also be
newlines, linebreaks, utf8-escape characters etc.

Personally I'd go the python route because it's simple and
straightforward, but anything you are comfortable with will do.
If you are going to install additional software to do this then remember
that you'll need that same software again if
you need to do this again, or when you need to move this code to a
different server.


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

Предыдущее
От: Albe Laurenz
Дата:
Сообщение: Re: [GENERAL] Request to confirm which command is use for exclusiveoperation
Следующее
От: John Iliffe
Дата:
Сообщение: Re: [GENERAL] Unable to start postgresql