#30476 [Bgs]: fgetcsv treats \" incorectly
| From: | andy at invocation dot ltd dot uk | Date: | Mon, 18 Oct 2004 22:14:52 +0000 |
| Subject: | #30476 [Bgs]: fgetcsv treats \" incorectly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-67750@lists.php.net to get a copy of this message | ||
ID: 30476
User updated by: andy at invocation dot ltd dot uk
Reported By: andy at invocation dot ltd dot uk
Status: Bogus
Bug Type: Filesystem function related
Operating System: Linux
PHP Version: 4.3.9
New Comment:
Thanks for looking at this, can you suggest a non broken spreadsheet
that runs under Linux or Windoze?
Previous Comments:
------------------------------------------------------------------------
[2004-10-18 23:52:56] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
There is only so much magic PHP can do to fix broken CSV feeds. The
current behaviour is correct.
------------------------------------------------------------------------
[2004-10-18 23:29:25] andy at invocation dot ltd dot uk
Description:
------------
The function fgetcsv assumes that a \ within a line of a CSV file is an
escape character, this is inconsistant with the csv output of most (if
not all) applications.
For example:
"foo","bar\","wombat"
Is 3 fields, but fgetcsv interprets this as 2 fields as the quote at
the end of bar is considered escaped.
Both Open Office and Microsoft Works (hence probably also Excel) would
genrate the above line from a spreadsheet looking like:
1 2 3
foo bar\ wombat
Gnumeric does not put quotes round each text field unless it has to
(i.e. contains a " or , in the text) but if you have:
foo b,ar\ wombat
you get:
foo,"b,ar\",wombat
This would again, I suspect, confuse the php fgetcsv function.
I appreciate that the csv file format is not covered by any proper
standards but it would be nice if its behaviour could be made
compatable with popular spreadsheets.
This is essentialy the same report is someone else submitted (#28347).
This was rejected, unfairly in my opinion, as bogus.
Reproduce code:
---------------
See Bug #28347 for example code and results.
Expected result:
----------------
See Bug #28347 for example code and results.
Actual result:
--------------
See Bug #28347 for example code and results.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30476&edit=1