0

I have a excel file like this:

      a
1 word1 : mean1
2 word2 : mean2
3 word3 : mean3
.
.

and I have saved this a cvs file. Can I import this cvs file to mysql with this table?

id   word   mean
1    word1  mean1
2    word2  mean2

I have tried CSV using LOAD DATA with Fields terminated by : and only ids imported. Thanks in advance

3 Answers 3

2

Make a copy of your Excel file. In the copy:

  • delete the row with the a in it.
  • delete the column with the colons.
  • insert a headings row, so that the spreadsheet looks like the table you want in MySQL.

Export the copy to CSV.

Create a database in phpMyAdmin.

Use these settings on the Import page of phpMyAdmin.

In the Format of imported file section, select CSV.

In the Options section, set the following:

  • Fields terminated by , (after all, it is a CSV file with comma separated values)
  • Fields enclosed by "
  • Column names in first row checked

In the File to import section, browse for the file on your computer, wherever you saved it.

Click the Go button.

Sign up to request clarification or add additional context in comments.

Comments

2

Your best bet is a short PHP script, something like this:

<?php

$fp = fopen('path-to-csv.csv','r');

while ($row = fgetcsv($fp)) {

$sql = "INSERT INTO `table` (`col1`,`col2`) VALUES ('{$row[0]}','{$row[1]')";
mysql_query($sql);

}

?>

1 Comment

I want to inset data thet separeted with ',' in two colomn.
0

use phpmyadmin

choose export as Excel 2007 XLSX Workbook

check the checkbox saying

Put fields names in the first row

Save as file. Thats all.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.