我有一个.csv文件,其行如下:
16.11.2015 00:00:01.118,0.94674,0.94641,1000000.0000,1750000.0000
现在我需要将mysql数据库的值导入到包含9个cols的表中,所以:
col1 - 16.11.2015 col2 - 00 col3 - 00 col4 - 01 col5 - 118 col6 - 0.94674 col7 - 0.94641 col8 - 1000000.0000 col9 - 1750000.0000
有人知道如何分离值f.e.使用标准命令: 加载数据infile' file.csv'表格名称字段由',';
终止我试图在mysql知识库上寻找一些东西,但没有结果,这将是有效的...谢谢
答案 0 :(得分:0)
你在找这样的东西吗?
$file_handle = fopen($file, "r"); //opens CSV
while (($row = fgetcsv($file_handle, 1000, ",")) !== false){
...code..
}
答案 1 :(得分:0)
i'd like to a direct mysql command if it is possible? i'd like to load the csv file directly to the DB with LOAD command.
答案 2 :(得分:0)
Have you looked at http://dev.mysql.com/doc/refman/5.7/en/load-data.html?
Also, some database manager/tools have the ability to import CSV files. I'm using Sequel Pro and it has the ability to do so.