in reply to Import CSV to Database

Take a look at the DBD::AnyData database driver for the Perl DBI. It has a ad_convert function which is specifically for translating between it's many supported database formats, which include DBI-supported DBMS'es and CSV format.

If all that's a little overwhelming, you could also use Perl to simply generate the SQL, then run the generated code against the database. Something like the following: (untested)

foreach ( @lines_from_text_file ) { chomp ; my @fields = split /,/ ; printf( "insert into my_table values\n" . "( %s, %s, %s, %s, %s, %s )\n", @fields ) ; }

This doesn't take into consideration the quoting of the appropriate fields, but you get the general idea.


_______________
D a m n D i r t y A p e
Home Node | Email