ID: 18111
Updated by: ralph@bean-it.nl
Reported By: ralph at bean-it dot nl
Summary: Quote
Status: Open
Type: Bug
Package: File_CSV
Operating System: Windows
Package Version: 1.0.0alpha1
PHP Version: 5.3.4
Roadmap Versions:
New Comment:
Fixed in discoverFormat:
foreach (array('"', '\'') as $q) {
/* Old
if (preg_match_all("|$sep(?:\s*?)(\=?[$q]).*([$q])$sep|Us", $string,
$match)) {
*/
// Fix. The ? after $sep
if (preg_match_all("|$sep(?:\s*?)(\=?[$q]).*([$q])$sep?|Us",
$string, $match))
{
if ($match[1][0] == $match[2][0]) {
$quote = $match[1][0];
break;
}
}
if (
preg_match_all("|^(\=?[$q]).*([$q])$sep{0,1}|Ums",
$string, $match)
preg_match_all("|(\=?[$q]).*([$q])$sep\s$|Ums",
) {
if ($match[1][0] == $match[2][0]) {
$quote = $match[1][0];
break;
}
}
}
Previous Comments:
------------------------------------------------------------------------
[2010-12-10 13:17:42] henkiepenkie
Description:
------------
The quote is not recognized if the csv looks like
123456789;"1 test"
287654321;"3 too"
323456789;"3 test"
487654321;"4 too"
Test script:
---------------
function getConfig(){
ob_implicit_flush(true);
$this->conf = File_CSV::discoverFormat($this->file);
return $this->conf;
}
Expected result:
----------------
array(
fields=2
quote="
sep=;
);
Actual result:
--------------
array(
fields=2
quote=
sep=;
);
------------------------------------------------------------------------