php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66126 SplFileObject READ_CSV ignores multi line csv data
Submitted: 2013-11-20 10:48 UTC Modified: 2015-04-15 14:56 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: m dot gribben at yellowsatsuma dot com Assigned: cmb (profile)
Status: Not a bug Package: SPL related
PHP Version: 5.4.22 OS: Ubuntu
Private report: No CVE-ID: None
 [2013-11-20 10:48 UTC] m dot gribben at yellowsatsuma dot com
Description:
------------
When running SplFileObject with the READ_CSV flag set, it does not obey the field enclosure setting (") and thus ignores any multi lined data in the CSV file, IE any data field with new lines in it.

Test script:
---------------
https://gist.github.com/anonymous/7561146

Expected result:
----------------
I would expect the code to read the file as a CSV and when a field is enclosed in the correct markup that its contents be treated as a single line of CSV regardless of it having new lines in it.

Actual result:
--------------
The code correctly reads most lines but when a field contains a new line it treats that as the end of that line of CSV, even when enclosed in double quotes.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-15 14:56 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2015-04-15 14:56 UTC] cmb@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

See <https://gist.github.com/anonymous/7561146#file-gistfile1-php-L18-L19>,
where the second call to SplFileObject::setFlags() overrides the
the first.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC