當我讀取CSV(使用PHPExcel,fgetcsv())時,我想在我的數據庫中導入行被切斷。使用PHP讀取Excel csv行被切斷
1 fields in line 1:
ProCatId;CatName;CatDescription;CatNameisactive;CatNameiswebactive;ProSubCatId;SubCatName;SubCatDesc;SubcatWebDiscription2;SubcatWebDiscription3;SubcatCatName;SubcatSequencenr;SubCatNameisactive;SubCatNameiswebactive;DisplayMode;ProductId;ProductName;ProductDescription;ProductCatName;ProductSubCatName;Express;NextDayDelivery;Sequencenr;Drukvorm;Afwerking;BreedteDrukwerk;HoogteDrukwerk;Papier;PrinterName;PrinterProductCode;WebDescription;WebDescription2;WebDescription3;DeliveryInfo;NextDayPrice;NextDayTransferPrice;NextDayCostPrice;Meta-Keywords;Meta-Description;URL-Trefwoorden;Titel;Filepath_icons;Format;MaterialType;NoOfPages;PrintFront;PrintBack;BleedTop;BleedBottom;BleedLeft;BleedRight;MINH;MAXH;MINW;MAXW;De
1 fields in line 2:
liveryScheduleId;DeliveryScheduleName;CentralProductDetailId;ClaimsId;ClaimsName;DruktechniekenId;DruktechniekenName;Verzameld op;Vast;Variabel;vorm;"prijs
1 fields in line 3:
drukken
這些領域應該是所有第1行中 當我使用PHP函數file_get_contents()函數的內容看起來有效。 在Excel中加載文件也沒有問題。
我用下面的代碼(,分隔):
<?php
if (($handle = fopen($inputFileName, "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />\n";
}
}
fclose($handle);
}
?>
我嘗試盲評論...取代「;」與「,」 –