CodeIgniter Forums
certain csv fields to mysql - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: certain csv fields to mysql (/showthread.php?tid=49478)



certain csv fields to mysql - El Forum - 02-21-2012

[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?


certain csv fields to mysql - El Forum - 02-21-2012

[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.