Re: php to import csv to postgres

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Chris <dmagick(at)gmail(dot)com>
Cc: SunWuKung <Balazs(dot)Klein(at)axelero(dot)hu>, pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: php to import csv to postgres
Date: 2006-04-06 23:52:02
Message-ID: 1144367522.32266.115.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2006-04-06 at 17:27, Chris wrote:
> SunWuKung wrote:
> > I am not sure I should be posting this here, but I guess you are the
> > people most likely be able to answer this.
> >
> > I have been looking for a user friendly php script to import csv into
> > Postgres (set separator, preview data, match columns - or any of these).
> > I found many for MySQL but none that would work with Postgres.
> >
> > Maybe somebody could direct me to such a script.
>
> Copy might be able to do it for you:
>
> http://www.postgresql.org/docs/8.1/interactive/sql-copy.html
>
> use ',' as the delimiter.

And, if you're stuck with an older version of PostgreSQL that can't do
cvs, you should look up this command:

http://us3.php.net/manual/en/function.fgetcsv.php

tres cool if you've got a csv file to import, you just read in each line
with that, and it gives you a numerically indexed array of each field,
ready to go. Quite useful, even for other stuff. And yes, it does
understand things like commas in the middle of the field and all that.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mike Adams 2006-04-07 00:01:11 Re: Cant find temp tables
Previous Message Chris 2006-04-06 22:27:34 Re: php to import csv to postgres