[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Software that will populate a database from csv data?



George (pinkisntwell@gmail.com on 2011-07-23 19:35 +0300):
> On Sat, Jul 23, 2011 at 1:11 PM, Liam O'Toole
> <otoolel@otoole.dyndns.org> wrote:
> > In gmane.linux.debian.user, you wrote:
> >> I'm looking for software that will accept as input a csv file and
> >> a database schema and will populate the database with the data in
> >> the csv. I'm not talking about something simple that will fill a
> >> single table, but rather something that can work foreign key
> >> constraints and can respect one-to-many, many-to-one and
> >> many-to-many relations.
> >
> > I don't have an answer to your question but I have to ask: how do
> > expect to express all of the above in a simple CSV file?
> 
> The data will be in the CSV file. The database schema will be needed
> as well, along
> with a mapping of CSV columns to database table columns.

I don't think you will easily find one. Compared to designing a
database schema and a meaningful csv mapping, writing a csv parser is
trivial (hint: awk). Since the only interesting part of your question
(the field->column mapping) is highly solution-dependant, I don't think
anyone will have ever bothered to write such a converter in a generic
way, and even if someone did, the burden of publishing and maintaining
it is far greater than its occasional use. But in case you are using
the only RDBMS that matters:

http://www.postgresql.org/docs/9.0/static/sql-copy.html


Regards,
Arno


Reply to: