summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHermann Herz <heart1010@gmail.com>2014-11-06 13:54:00 +0100
committerIgnace Nyamagana Butera <nyamsprod@gmail.com>2014-11-07 10:42:19 +0100
commitc14b04f2112c15103efeacf1658c9ff756a69255 (patch)
tree35d9c2eaad0bfbd49afdd04a0302ac5b48e087bf /src
parent54c594eea3b96af11def4bbd1a73d94e7c410201 (diff)
downloadcsv-c14b04f2112c15103efeacf1658c9ff756a69255.zip
csv-c14b04f2112c15103efeacf1658c9ff756a69255.tar.gz
csv-c14b04f2112c15103efeacf1658c9ff756a69255.tar.bz2
Bug Fix detectDelimiterList by adding COUNT_RECURSIVE
Discussion see #55 At the moment detectDelimiterList method doesn't find the correct delimiter when there are 2 or more potential delimiters in the csv line. For example if there are 30 semicolons (;) and only one comma (,) in the checked csv line the method doesn't find the correct delimiter anymore and returns only both found occurences (";" and ","). This is because fetchRowsCountByDelimiter method (when we use default $nb_rows = 1 value) always prints 1 for both found delimiters as a result regardless if there are 30 semicolons and only one comma there. So I added the COUNT_RECURSIVE mode in fetchRowsCountByDelimiter method in order we get a relation how often a delimiter is present in the line(s). In the detectDelimiterList method we can then change the return line so it only returns the delimiter with the most occurences. To make that even more robust we return only one delimiter if it's occurence is way higher then the occurence of the 2nd found delimiter (I choosed 2.5x the times here). If its quantity is not way higher we return all found delimiters like it is now.
Diffstat (limited to 'src')
-rw-r--r--src/Config/Controls.php2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/Config/Controls.php b/src/Config/Controls.php
index b09713b..96ae302 100644
--- a/src/Config/Controls.php
+++ b/src/Config/Controls.php
@@ -109,7 +109,7 @@ trait Controls
return is_array($row) && count($row) > 1;
});
- return count(iterator_to_array($iterator, false));
+ return count(iterator_to_array($iterator, false), COUNT_RECURSIVE);
}
/**