PHP Script to transfer csv file to MySql
Posted on 2012-04-09
I need a script that will transfer a csv file to a table in my db. Sounds pretty straightforward but I'm going to throw a slight kink in it...
The csv file and the db table do not match. I'm going from mssql to mysql and I've dumped all the data from each table in to a csv file. My company is converting our asp site to a php site and the information we handle is Law Enforcement Sensitive so they have to have someone with the proper security clearance to do it. When the new site db was made, a lot of features are different or upgraded and no longer needed. So in my csv file I have for instance:
First_Name, Last_Name, email, password, date_joined, date_last_posted
and in the new db I would have the fields:
name, email, password, something else, ...etc
The way I was thinking in my head was taking each csv line and explode() the comma's and then use the array keys to enter the data? I'm sure there is probably an easier way. I need all the help I can get.
There are around 51,000 users if that makes a difference but the largest csv file is well over 250k records.