CodeIgniter Forums

Full Version: certain csv fields to mysql
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]trinic[/eluser]
I have a csv (dump from mssql) that I would like to put in to a mysql table. The only catch is I would like to be able to format it with code because the tables do not match up perfectly. For example if my csv was:

first name, last name, address, city, state, other

and I only wanted to add first name, last name and other

How would I go about this?

El Forum

[eluser]johnpeace[/eluser]
I would go about it using Sequel Pro's (my OS X MySQL client) excellent CSV import feature.

If it has to be done repeatedly as part of the app, you'll probably need to write a script that will loop through each row and parse each cell into the correct field in your table. I'm sure countless examples of how to do that can be found online.