#43835 [Opn->Bgs]: misstyped fields num in actual results
| From: | iliaa@php.net | Date: | Mon, 14 Jan 2008 13:39:44 +0000 |
| Subject: | #43835 [Opn->Bgs]: misstyped fields num in actual results | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-121265@lists.php.net to get a copy of this message | ||
ID: 43835
Updated by: iliaa@php.net
Reported By: alexander dot varchenko at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: FreeBSD,Linux,Windows
PHP Version: 5.2.5
New Comment:
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.
An invalid CSV format is not going to be supported. The enclosure
character needs to be escaped to ensure proper data parsing.
Previous Comments:
------------------------------------------------------------------------
[2008-01-14 00:20:23] alexander dot varchenko at gmail dot com
! In Actual Result -> 3 fields in line x
------------------------------------------------------------------------
[2008-01-14 00:17:07] alexander dot varchenko at gmail dot com
Description:
------------
Not every programs escapes enclosure characters,
so it's should be good to check enclosures by delimiters chars
start =delimiter+enclosure
fin = enclosure+delimiter
TEST data: test.csv [TSV]
1[tab]"NOAA "Official" Emergency"[tab]01/09/2008
2[tab]"Tories "reject" green" panel's advice"[tab]01/09/2008
Reproduce code:
---------------
<?
$handle = fopen('test.csv','rb');
$row = 1;
while (($data = fgetcsv($handle, 1000, "\t",'"')) !== FALSE) {
$num = count($data);
echo "$num fields in line $row\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo "[$c]:".$data[$c]."\n";
}
}
fclose($handle);
?>
Expected result:
----------------
3 fields in line 1
[0]:1
[1]:NOAA "Official" Emergency
[2]:01/09/2008
3 fields in line 2
[0]:2
[1]:Tories "reject" green" panel's advice
[2]:01/09/2008
Actual result:
--------------
4 fields in line 1
[0]:1
[1]:NOAA Official" Emergency"
[2]:01/09/2008
4 fields in line 2
[0]:2
[1]:Tories reject" green" panel's advice"
[2]:01/09/2008
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43835&edit=1