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

ID: 15233
Updated by: [email protected]
Reported By: bs at visual4 dot de
Summary: discoverFormat finds wrong separator
-Status: Open
+Status: Feedback
Type: Bug
Package: File_CSV
Operating System: linux (irrelevant)
Package Version: 1.0.0alpha1
PHP Version: Irrelevant
Roadmap Versions:
New Comment:

-Status: Open
+Status: Feedback

We are unable to reproduce the bug as reported.
Please provide a simple script (10 lines or less)
or a link to an external script that can be used
to reproduce the bug.

If you can provide the script, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PEAR.





Previous Comments:
------------------------------------------------------------------------

[2008-12-06 06:26:21] doconnor

I don't suppose you could whip up a small executable test case, Bjorn?

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

[2008-12-04 10:01:35] brafreider

Description:
------------
If I read a CSV with one line that contains ";" as separators and ","
in unquoted fields, discoverformat() sets "," as separator. This will
eqaully happen if you have a CSV with at least one "," in every line, as
$amount will have the same line count for the two separators.

I have done a workaround if $amount[0]==$amount[1] after the
arsort($amount)

CSV.php; line 558ff:
$final = array();
$max = array();
// Group the results by amount of equal ocurrences

foreach ($matches as $sep => $res) {
$times = array();
$times[0] = 0;

foreach ($res as $k => $num) {
if ($num > 0) {
$times[$num] = (isset($times[$num])) ? $times[$num]
+ 1 : 1;
}
$max[$sep] = ($num > $max[$sep])?$num:$max[$sep];
}
arsort($times);

// Use max fields count.
$fields[$sep] = max(array_flip($times));
$amount[$sep] = $times[key($times)];
}

arsort($amount);
arsort($max);
if ($amount[0] > $amount[1]){
$sep = key($amount);

}else{
$sep = key($max);
}

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

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedMar 12, '09 at 11:06p
activeMar 12, '09 at 11:06p
posts1
users1
websitepear.php.net

1 user in discussion

Helgith: 1 post

People

Translate

site design / logo © 2023 Grokbase