LOAD DATA INFILE已执行但零行受影响

时间:2017-01-08 00:20:06

标签: php mysql excel csv

我在我的csv文件中添加了两个包含一些Excel公式的列,因为我需要将MySQL数据下载为excel文件,其中这些公式将作出反应。

但是在添加这两个附加列后,数据不会插入到表中。

我的代码是:

$a = file('/Applications/XAMPP/xamppfiles/htdocs/upload/data.csv');// get array of lines
$new = '';
$i=1;
//$formula1 = "=IF(A$i>=40,2,IF(A$i=20,1))";
foreach($a as $line){
    $line = trim($line);// remove end of line
    $line .="|=IF(A$i>=40,2,IF(A$i=20,1))"."|=IF(COUNTIF(\$B:\$B,B".$i.")=1,1,C".$i."/COUNTIF(\$B:\$B,B".$i."))";// append new column
    $new .= $line.PHP_EOL;//append end of line
    $i++;
}
$outputfile = file_put_contents('/Applications/XAMPP/xamppfiles/htdocs/upload/data.csv', $new);// overwrite the same file with new data


$termit = "|";
$encls = "'\"'";
$lyn = "'\r\n'";

$cvsfile = "'/Applications/XAMPP/xamppfiles/htdocs/upload/data.csv'";

$dalete = mysql_query("delete FROM upload_excel_file");
$data_upload = mysql_query ("LOAD DATA INFILE $cvsfile INTO TABLE $cvsfile FIELDS TERMINATED BY '|' ENCLOSED BY $encls LINES TERMINATED BY $lyn IGNORE 1 LINES;");

0 个答案:

没有答案