* fix a bug for parse csv.

This commit is contained in:
wangyidong
2014-08-05 02:26:12 +00:00
parent 7a0fe98744
commit 3230f9fca7
+3 -3
View File
@@ -312,7 +312,7 @@ class fileModel extends model
else
{
$data[$row][$col] .= "\n" . substr($line, 0, $pos + 1);
$data[$row][$col] = str_replace(',', ',', trim($data[$row][$col], '"'));
$data[$row][$col] = trim(str_replace(',', ',', trim($data[$row][$col], '"')));
$line = substr($line, $pos + 2);
$col++;
}
@@ -330,7 +330,7 @@ class fileModel extends model
{
$data[$row][$col] = $line;
/* if end of cell is not '"', then the data of cell is not end. */
if($line{strlen($line) - 1} != '"') continue 2;
if(strlen($line) == 1 or $line{strlen($line) - 1} != '"') continue 2;
$line = '';
}
else
@@ -357,7 +357,7 @@ class fileModel extends model
}
}
$data[$row][$col] = str_replace(',', ',', trim($data[$row][$col], '"'));
$data[$row][$col] = trim(str_replace(',', ',', trim($data[$row][$col], '"')));
$col++;
}
}