import csv file into mysql database with phpMyAdmin

When you start to design website for your client , and sometimes your client will give you a csv or txt file which include large data in it . so you should import it into database and use it. which way is the best to do this? I think phpMyAdmin is the best choice. The example is that a client provide a txt file , exported with CSV formate . and they want to these data into the database and query online store in the website.
First , see the csv or txt file , make sure all the line is the same type, like this :
"14 Carrot Whole Foods Inc.","5300 Sunset Blvd.","Lexington","SC","29072","803-359-3920"
"365 Nutrition","1205 Johnson Ferry Rd.","Marietta","GA","30068","770-509-3644"
"4 Goodness Sake","3538 Route 309","Orefield","PA","18069","610-398-2057"
"A & A Health Foods","99 Godwin Avenue","Midland Park","NJ","07432","201-447-3130"

Then analyze the file and make sure the content for field in database. see above, and you will know that the filed order is :

store_name,store_address,store_city,store_state,store_zip,store_phone
the field names above are in the table which you want to import into.

Second , open browser and visit phpMyAdmin, select a database and table you want to import into.
Then click Import button, and select CSV in Format of imported file section.and check the value is right with csv file or txt file.

Fields terminated by ;
Fields enclosed by "
Fields escaped by \
Lines terminated by AUTO
Column names store_name,store_address,store_city,store_state,store_zip,store_phone

Last, click Go button in right bottom, It will import into table.

and import thing , please make sure you are using test database , or just backup database first , because I had make some mistakes with database before. just see this article : IMPORTANT:BACKUP!备份!网站备份方法一例!

Leave a Reply