From 3230f9fca7e0b3daec7f1978c7e17574f3e7f149 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Tue, 5 Aug 2014 02:26:12 +0000 Subject: [PATCH] * fix a bug for parse csv. --- module/file/model.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/file/model.php b/module/file/model.php index 5bd10ae883..93dd5c2212 100644 --- a/module/file/model.php +++ b/module/file/model.php @@ -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++; } }