Demo image Demo image Demo image Demo image Demo image Demo image

Steps to Import CSV into MySQL table

  • Friday, July 9, 2010
  • zana991
  • Steps to Import CSV into MySQL table

    * Step 1) Create a table that has the necessary number of columns. If the CSV has 10 types of data, you'll need 10 columns.
    * Step 2) After having created you MySQL table, log into phpMyAdmin and click on this table.I had a table called `morris_zipcodes`.
    * Step 3) Click on the 'import ' (For this step you can refer to the picture below







    * Step 4) You should now be looking at something like the next picture. I circled in red the important parts of the form.




    * Step 5) Click on the 'csv' radio button. You will then see a fields that have to do with your CSV is formatted. Since my CSV's fields were not separated by tabs I entered '\t' as you can see above (no quotes). My fields were not enclosed by quotes so I removed the default quotation marks for 'Fields enclosed by'. I left the fields escaped by in its default form (didn't need to worry about escaping). And lastly, since my lines were terminated by a new line I entered the '\n' for the 'lines terminated by' field.
    * Step 6) I browsed to the massive text file, uploaded it and was soon happily greated by this message : "Import has been successfully finished, 79948 queries executed." WOw that's a lot of queries. I think it took about a minute or two, for MySQL to create all of those rows, not bad!

    0 comments: