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

 ID:                 53822
 User updated by:    withskyto at naver dot com
 Reported by:        withskyto at naver dot com
 Summary:            fgetcsv parsing error
-Status:             Closed
+Status:             Open
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   freebsd
 PHP Version:        5.2.17
 Block user comment: N
 Private report:     N

 New Comment:

Change Status


Previous Comments:
------------------------------------------------------------------------
[2011-01-23 15:49:35] withskyto at naver dot com

change Package

------------------------------------------------------------------------
[2011-01-23 15:09:21] withskyto at naver dot com

I check this file.

OpenOffice.org Calc and MS Offie excel - It seems to parse properly.

------------------------------------------------------------------------
[2011-01-23 15:01:05] withskyto at naver dot com

Description:
------------
I save csv file from MS Office excel.



The file looks as below.



A,B,C,D

AAA,"BB,B","CCC,'\C,,CCC","D,DDD"

"AA""AA","BB"",BBB""B","CC\""CC,,C""",DDD





fgetcsv seems to be incorrect, if the cell in EXCEL include escape
string.





Test script:
---------------
$fp = fopen('test3.csv', 'r');

while ($arr = fgetcsv($fp, 10000, ',', '"')) {

  print_r($arr);

}

Expected result:
----------------
Array

(

    [0] => A

    [1] => B

    [2] => C

    [3] => D

)

Array

(

    [0] => AAA

    [1] => BB,B

    [2] => CCC,'\C,,CCC

    [3] => D,DDD

)

Array

(

    [0] => AA"AA

    [1] => BB",BBB"B

    [2] => CC\"CC,,C"

    [3] => DDD

)

Actual result:
--------------
Array

(

    [0] => A

    [1] => B

    [2] => C

    [3] => D

)

Array

(

    [0] => AAA

    [1] => BB,B

    [2] => CCC,'\C,,CCC

    [3] => D,DDD

)

Array

(

    [0] => AA"AA

    [1] => BB",BBB"B

    [2] => CC\"CC

    [3] =>

    [4] => C"""

    [5] => DDD

)




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



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53822&edit=1

Reply via email to