Reputation: 5802
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
Upvotes: 0
Views: 1421
Reputation: 4569
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.
Upvotes: 0
Reputation: 5432
Make a copy of your Excel file. In the copy:
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:
In the File to import section, browse for the file on your computer, wherever you saved it.
Click the Go button.
Upvotes: 2
Reputation: 1520
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);
}
?>
Upvotes: 2