Bug #50686 [Com]: fputcsv and fgetcsv doesn't follow CSV format

From: Date: Thu, 17 Oct 2019 14:11:25 +0000
Subject: Bug #50686 [Com]: fputcsv and fgetcsv doesn't follow CSV format
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223222@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=50686&edit=1

 ID:                 50686
 Comment by:         bugreports at gmail dot com
 Reported by:        thuejk at gmail dot com
 Summary:            fputcsv and fgetcsv doesn't follow CSV format
 Status:             Wont fix
 Type:               Bug
 Package:            Filesystem function related
 Operating System:   *
 PHP Version:        5.*, 6
 Assigned To:        iliaa
 Block user comment: N
 Private report:     N

 New Comment:

what would you gain by deprecate it?

it only would bring users using it for their workloads for 15 years without any issue in trouble and
you still won#t have something mathcing your needs


Previous Comments:
------------------------------------------------------------------------
[2019-10-17 14:04:45] durinf at gmail dot com

Hey, if ya'll are too lazy to fix this, how about at least deprecating it?
Sheesh.

------------------------------------------------------------------------
[2017-04-11 18:43:49] plenty dot su at gmail dot com

I mentioned in: https://bugs.php.net/bug.php?id=43225
A workaround so far is to disable escape method by: fputcsv($handle, $array, ',',
'"', "\0")

------------------------------------------------------------------------
[2017-02-09 17:03:49] aleksey dot spec at gmail dot com

Please, change the behaviour or provide another function. We have problems while preparing csv-files
for ClickHouse.
When I write
$string = '\\"';
fputcsv($fileHandle, [$string]);
I expect to see this in my file:
"\"""
but currently I see 
"\""

Csv is often used for communications between different environments, not only inside php with
fputcsv/fgetcsv. so it would be much better if generated csv file obeys some commonly used standard
like RFC 4180.

P.S. Please, do not take personally. I really love php and I'd like it to become even more
beautiful and popular.

------------------------------------------------------------------------
[2016-09-23 17:17:15] office at williamhollandschool dot com

I see that the versions entry only lists 5.* and 6. I use PHP 7 and the "escape" character
thing has caused me no end of grief in trying to implement import and export of natural language
documents into and out of CSV format to later be interpreted by MariaDB's LOAD INFILE. Even
trying the workaround that's posted everywhere of putting the "escape" character the
same as the enclosure character only caused it to fail to escape any enclosure characters. Having to
generate then fix giant files by hand is what has driven me to Python for this task. Many, many
things are still using CSV. Not the most important bug in PHP 7, but one that has annoyed me to no
end.

------------------------------------------------------------------------
[2016-01-05 14:08:11] minexew at gmail dot com

Is there any chance that this will be fixed?
As of today, the documentation for fgetcsv is still misleading and there is no simple workaround.

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=50686


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


Thread (17 messages)

« previous php.bugs (#223222) next »