Import textfile as table

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

Import textfile as table

От:
Michelle Konzack <linux.mailinglists@freenet.de>
Дата:
Hello, 

I have gotten a 16 MByte textfile with around 27.000 lines of data 
which contains a database with 22 fields which are  seperated. 

How can I import it into a (new) table and or new 
database of pgsql. 

Thanks in advance 
Michelle

-- 
Registered Linux-User #280138 with the Linux Counter, http://counter.li.org.

Re: Import textfile as table

От:
"Shridhar Daithankar" <shridhar_daithankar@persistent.co.in>
Дата:
On 2 Oct 2002 at 18:01, Michelle Konzack wrote:

> Hello, 
> 
> I have gotten a 16 MByte textfile with around 27.000 lines of data 
> which contains a database with 22 fields which are  seperated. 
> 
> How can I import it into a (new) table and or new 
> database of pgsql. 

You can use \copy in psql. I don't know how would you specify tab as delimeter. 
May be you should convert it to some other delimeter like ':' or ',' if tab 
does not work.

Get a small chunk of that file. First 100 records or so and experiment. 
Otherwise it might get quite irritating..;-)


Bye
 Shridhar

--
White's Statement:	Don't lose heart!Owen's Commentary on White's Statement:	
...they might want to cut it out...Byrd's Addition to Owen's Commentary:	...and 
they want to avoid a lengthy search.

Re: Import textfile as table

От:
"Nigel J. Andrews" <nandrews@investsystems.co.uk>
Дата:
On Thu, 3 Oct 2002, Shridhar Daithankar wrote:

> On 2 Oct 2002 at 18:01, Michelle Konzack wrote:
> 
> > Hello, 
> > 
> > I have gotten a 16 MByte textfile with around 27.000 lines of data 
> > which contains a database with 22 fields which are  seperated. 
> > 
> > How can I import it into a (new) table and or new 
> > database of pgsql. 
> 
> You can use \copy in psql. I don't know how would you specify tab as delimeter. 
> May be you should convert it to some other delimeter like ':' or ',' if tab 
> does not work.

Tab is the separator for COPY. I'm not sure about \copy but I presume it's
going to be the same since it probably only does a copy in from stdin.

> 
> Get a small chunk of that file. First 100 records or so and experiment. 
> Otherwise it might get quite irritating..;-)

Very irritating.


-- 
Nigel J. Andrews

Re: Import textfile as table

От:
"scott.marlowe" <scott.marlowe@ihs.com>
Дата:
On Thu, 3 Oct 2002, Shridhar Daithankar wrote:

> On 2 Oct 2002 at 18:01, Michelle Konzack wrote:
> 
> > Hello, 
> > 
> > I have gotten a 16 MByte textfile with around 27.000 lines of data 
> > which contains a database with 22 fields which are  seperated. 
> > 
> > How can I import it into a (new) table and or new 
> > database of pgsql. 
> 
> You can use \copy in psql. I don't know how would you specify tab as delimeter. 
> May be you should convert it to some other delimeter like ':' or ',' if tab 
> does not work.
> 
> Get a small chunk of that file. First 100 records or so and experiment. 
> Otherwise it might get quite irritating..;-)

Actually, tab is the default seperator for pg_dump and copy, so it should 
work as is.

Re: Import textfile as table

От:
Michelle Konzack <linux.mailinglists@freenet.de>
Дата:
Hello, 

if you seed it sometimes... thanks to 'rovero'

>Run psql......
>create table table_name.........
>copy table_name from '/full/path/to/file' using delimiters '\t';

Michelle


Am 15:34 2002-10-03 +0530 hat Shridhar Daithankar geschrieben:
>
>On 2 Oct 2002 at 18:01, Michelle Konzack wrote:
>
>> Hello, 
>> 
>> I have gotten a 16 MByte textfile with around 27.000 lines of data 
>> which contains a database with 22 fields which are  seperated. 
>> 
>> How can I import it into a (new) table and or new 
>> database of pgsql. 
>
>You can use \copy in psql. I don't know how would you specify tab as delimeter. 
>May be you should convert it to some other delimeter like ':' or ',' if tab 
>does not work.
>
>Get a small chunk of that file. First 100 records or so and experiment. 
>Otherwise it might get quite irritating..;-)
>
>
>Bye
> Shridhar
>
>--
>White's Statement:	Don't lose heart!Owen's Commentary on White's Statement:	
>...they might want to cut it out...Byrd's Addition to Owen's Commentary:	...and 
>they want to avoid a lengthy search.
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>
> ##########  Get the Power of Debian/GNU-Linux  ##########
FAQ