Обсуждение: Importing complete txt file with column names

Поиск
Список
Период
Сортировка

Importing complete txt file with column names

От
robert kraus
Дата:
hi,

I have multiple huge tab delimited txt files with >500
columns which I want to import, The name of the
columns is important, has to be the name of the column
in the table and is always very long. The copy command
seems to work only with predefined tables. How do I
import the tables with column names ?

thank you very much for your answer
robert



__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com



Re: Importing complete txt file with column names

От
Josh Jore
Дата:
This is where you grab your trusty language of choice (scripting most
likely) and write a one-off to take input like:

attr\tattr0\tattr1....
0\t1\t2\t.....

and turn it into

CREATE TABLE ... (
    attr ....?,
    attr0 ....?,
    attr1 ....?
    .....
);
COPY ....
0\t1\t2\t....

This isn't a hard problem but since there are specific thing where the
column types aren't known in advance there isn't any prebuilt tool for
this. Mostly you get to write it yourself. It's short - just do it.


Joshua b. Jore ; http://www.greentechnologist.org

On Tue, 2 Jul 2002, robert kraus wrote:

> hi,
>
> I have multiple huge tab delimited txt files with >500
> columns which I want to import, The name of the
> columns is important, has to be the name of the column
> in the table and is always very long. The copy command
> seems to work only with predefined tables. How do I
> import the tables with column names ?
>
> thank you very much for your answer
> robert