Can anybody point me to some PHP or Perl code which will create a mysql table from an arbitrary TSV file?
Based on the data found and some parameters, it would use its logic to work out appropriate field types for each field, create the database table, and upload the data. (i.e. the table structure isn’t known in advance).
(Alternatively I could imagine it creating an initial table with a general text type, then running sql queries to analyse the data, then altering the table structure to match the data.)
The only solution I found was in in the MYSQL Cookbook
http://www.kitebird.com/mysql-cookbook/
Code samples at: http://www.kitebird.com/mysql-cookbook/downloads-2ed.php
This does the first piece…analyse TSV data and generate a “CREATE TABLE” appropriate for it.
The second piece, uploading the TSV into the table structure, is simple and common.
guess_table.pl