importing csv into mysql database - advice and pointers plz

Associate
Joined
24 Jul 2004
Posts
1,580
Location
Preston, Lancs
Hi,

A quick overview of the scenerio - I get given csv files by clients containing records for my database. As a quick example lets say my table has 5 fields and the CSV files contain anything from 2-5 pieces of information per record, delimited randomly. The other fun feature is that the clients providing the csv files do not follow a standard order for the information.

A more in depth look would be something like this:

My database > Table > Sex
My database > Table > Age
My database > Table > Smoker
My database > Table > Religion
My database > Table > Nationality

CSV file from client A:

male, 18, smoker, , british
male, 30, non-smoker, ,
female, , non-smoker, catholic,
female, 22, non-smoker, muslim, irish

CSV file from client B:

male|20|smoker||
female|30|non-smoker||welsh
|40|smoker||cornbeef

CSV file from client C:

smoker female welsh 20
non-smoker male scottish hindu


And so on, you get the idea. I would be importing these files on a file by file basis, rather than all at once. Each CSV would contain around 50-200 rows, sometimes lots more, sometimes less.

I want to use a form with 5 drop down boxes and a text area. I would paste the contents of the CSV file into the text box, using the 'return' to indicate a new database table row.

Using the drop downs I would like to select which field came in what order.

Null fields are not a concern currently, as my database doesnt worry about them.

Is there a script out there that will do this for me? If not, can anyone begin to point me in the best direction of achieving this?

Thanks
 
Back
Top Bottom