FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=18111&edit=1

ID: 18111
Updated by: helgith@gmail.com
Reported By: ralph at bean-it dot nl
-Summary: Quote
+Summary: discoverFormat: Quote not detected in short lines
Status: Open
Type: Bug
Package: File_CSV
Operating System: Windows
Package Version: 1.0.0alpha1
PHP Version: 5.3.4
-Assigned To:
+Assigned To: dufuz
Roadmap Versions:
New Comment:

-Summary: Quote
+Summary: discoverFormat: Quote not detected in short
lines
-Assigned To:
+Assigned To: dufuz



Previous Comments:
------------------------------------------------------------------------

[2010-12-10 13:22:46] henkiepenkie

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",
$string, $match)
) {
if ($match[1][0] == $match[2][0]) {
$quote = $match[1][0];
break;
}
}
}

------------------------------------------------------------------------

[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=;
);

------------------------------------------------------------------------

Search Discussions

  • Helgith at Mar 10, 2011 at 8:24 pm
    Edit report at http://pear.php.net/bugs/bug.php?id=18111&edit=1

    ID: 18111
    Updated by: helgith@gmail.com
    Reported By: ralph at bean-it dot nl
    Summary: discoverFormat: Quote not detected in short lines
    -Status: Assigned
    +Status: Closed
    Type: Bug
    Package: File_CSV
    Operating System: Windows
    Package Version: 1.0.0alpha1
    PHP Version: 5.3.4
    Assigned To: dufuz
    Roadmap Versions:
    New Comment:

    -Status: Assigned
    +Status: Closed
    This bug has been fixed in SVN.

    If this was a documentation problem, the fix will appear on pear.php.net
    by the end of next Sunday (CET).

    If this was a problem with the pear.php.net website, the change should
    be live shortly.

    Otherwise, the fix will appear in the package's next release.

    Thank you for the report and for helping us make PEAR better.




    Previous Comments:
    ------------------------------------------------------------------------

    [2011-03-10 20:18:51] dufuz

    -Summary: Quote
    +Summary: discoverFormat: Quote not detected in short
    lines
    -Assigned To:
    +Assigned To: dufuz


    ------------------------------------------------------------------------

    [2010-12-10 13:22:46] henkiepenkie

    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",
    $string, $match)
    ) {
    if ($match[1][0] == $match[2][0]) {
    $quote = $match[1][0];
    break;
    }
    }
    }

    ------------------------------------------------------------------------

    [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=;
    );

    ------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedMar 10, '11 at 7:15p
activeMar 10, '11 at 8:24p
posts2
users1
websitepear.php.net

1 user in discussion

Helgith: 2 posts

People

Translate

site design / logo © 2022 Grokbase