当我读取CSV (使用PHPExcel,fgetcsv())时,我想要导入的数据库行被切断。
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);
}
?>发布于 2016-02-25 11:31:05
让我们看看文档是怎么说的:
array fgetcsv (
resource $handle
[, int $length = 0
[, string $delimiter = ","
[, string $enclosure = '"'
[, string $escape = "\" ]]]] )你正在通过一个$handle,很好。
你的意思是“切掉1000个字符的一行”--用你的数据来说,这可能会成为一个问题,考虑更高的限制(8000?)
你说的是“字段由,分隔”。看起来他们实际上是被;隔开的。也许这也是问题的一部分?
(另外,fgetcsv并不是二进制安全的,所以如果您的数据不是普通的ASCII,见这个问题。)
https://stackoverflow.com/questions/35625632
复制相似问题