CodeIgniter Forums
Excel(csv) import with simple validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Excel(csv) import with simple validation (/showthread.php?tid=67560)



Excel(csv) import with simple validation - apysan - 03-09-2017

Hello Friends,
I have a product table called t_product
having just 4 fields
1. id (ai)
2. poroduct
3. generic_name
4. description
5. status
I have to populate this table from excel file.
I can easily import the file no issue but i have to check if a particular product exist it should not be imported at all.
How can i do that just share the logic (good if you have a code for it) should i import the data from excel to a temporary table and then do the checking or is it possible to import and validate simultaniously
Please Help


RE: Excel(csv) import with simple validation - AzrielOmega - 03-09-2017

Load into an array and use foreach and if else to check

I found this mySQL solution, only need to convert to CI query builder
http://stackoverflow.com/questions/3164505/mysql-insert-record-if-not-exists-in-table

or this
http://stackoverflow.com/questions/35223752/codeigniter-insert-if-not-exist-and-update-if-not/35223951


RE: Excel(csv) import with simple validation - skunkbad - 03-09-2017

I use this all the time:
https://github.com/parsecsv/parsecsv-for-php

It's been perfect for me.