Skip site navigation (1) Skip section navigation (2)

Re: extract data and store

From: Jesús López <jesulop1(at)etb(dot)com(dot)co>
To: aarni(dot)ruuhimaki(at)kymi(dot)com
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: extract data and store
Date: 2002-07-25 16:56:15
Message-ID: 3D402DAF.48D793A8@etb.com.co (view raw or flat)
Thread:
Lists: pgsql-novice
Hi !

I have only one more question before test the solution. If i have another file
type with the following structure :


   30 INC ANSW
   . . . . . . . . . CENTROB     . . . . . . . .          7
   1024 INC FAIL OWN
   . . . . . . . . . CENTROB     . . . . . . . .          0

etc.......

I need to extract some info from file to postgress, I supose is necesary to parse
file. What if the best form to do it ? Whit perl and pipe files ? or there are a
diferent form  ?

Thanks.

Jlopez.

Aarni Ruuhimäki / Megative Tmi / KYMI.com wrote:

> Hi !
>
> How about COPY mytable FROM '/tmp/plain.txt' USING DELIMITERS ',';
>
> Taken that your file is in rows, one row for one record, no need for parsing
> or linefeeds / linebreaks:
>
> Like
>
> 253,0,2000-02-24,053638447fffffffffffffff,.......................
> 254,0,2000-02-25,053638448fffffffffffffff,.......................
>
> Of course you will have to first create the table according to your data:
>
> int, boolean?, date, varchar, ...............
>
> BR,
>
> aarni
>
> On Thursday 25 July 2002 07:16 pm, you wrote:
> > Hi:
> >
> > Thanks for your answer. My question is the following:
> >
> > I have a large plain text external file with registers separated by commas
> > like this:
> >
> > 253,0,2000-02-24,053638447fffffffffffffff,.......................
> >
> > I need to parse this and put in postgres. What is the best form of parsing
> > and how can I do for put this information in database.
> >
> > Thanks again for your help.
> >
> > Jlopez.
> >
> > Aarni Ruuhimäki / Megative Tmi / KYMI.com wrote:
> > > Hi Jesus !
> > >
> > > You can use COPY command in psql to import txt and csv files.
> > >
> > > If you want just parts from your text you will have to search / parse the
> > > file first.
> > >
> > > For the parsing, I am afraid, you will have to write a bit of code in
> > > your preferred language. If you are using some common tools / APIs like
> > > php or cfml, there are plenty of custom functions and little scriplets
> > > readily available.
> > >
> > > Could you be a little more specific on 'some information' and 'external
> > > text file' please ?
> > >
> > > BR,
> > >
> > > aarni
> > >
> > > On Thursday 25 July 2002 02:29 am, you wrote:
> > > > Hi:
> > > >
> > > > I´m novice in postgress and i need to take some information from a
> > > > external plain text file and store in postgress.
> > > >
> > > > There are any aplication to do that ? what is the best form to do it?
> > > >
> > > > Thanks.
> > > >
> > > > Jlopez.
> > > >
> > > >
> > > >
> > > > ---------------------------(end of
> > > > broadcast)--------------------------- TIP 4: Don't 'kill -9' the
> > > > postmaster


In response to

pgsql-novice by date

Next:From: J.T. HartzlerDate: 2002-07-25 17:02:20
Subject: Re:
Previous:From: Aarni Ruuhimäki / Megative Tmi / KYMI.comDate: 2002-07-25 16:37:02
Subject: Re: extract data and store

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group