in reply to Creating Table and Inserting Data from CSV
Also in MySQL 4, it now supports a CSV engine. If you have that enabled, you might be able to just write your file into the mysql data dir and have it work. I haven't tried it, so I won't recommend it. One more thing, I'd suggest using the SQL load data infile or the commandline mysqlimport to actually import the data.use Text::xSV; my $csv = new Text::xSV; $csv->open_file("foo.csv"); $csv->read_header(); my $SQL = "CREATE TABLE $table_name("; foreach my $field ($csv->get_fields) { $SQL .= $field . " varchar(255),"; } $SQL .= "); # then connect to the database and run the query
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating Table and Inserting Data from CSV
by awohld (Hermit) on Oct 04, 2005 at 19:48 UTC | |
by sk (Curate) on Oct 04, 2005 at 20:06 UTC |