Quickly Import Flat-File Data into MySQL

I often find myself needing to import flat file data from various vendors. Recently I decided to try and simplify this for most of the basic cases and create a simple converter using standard *nix commands. It attempts to semi optimize the mysql to do batch inserts to speed things up. There are a lot of presumptions made in this script that could be easily modified to fit your needs. Firstly, this assumes that your input is a tab separated file with no quoting of fields. This obviously also implies your data can not have tabs in it. if you have a simple CSV you may have luck replacing the \t on line 11 with a , to import CSV files. Secondly, rather than intelligently trying to guess or ask for data types to create the table this assumes text type, which you can than more quickly convert in mysql into…