SImplify separator inference code (#903)

This commit is contained in:
Mark Baker 2019-02-24 23:55:08 +01:00 committed by GitHub
parent df1085505c
commit f26023586e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 6 deletions

View File

@ -155,7 +155,7 @@ class Csv extends BaseReader
return;
}
$potentialDelimiters = [',', ';', "\t", '|', ':', ' '];
$potentialDelimiters = [',', ';', "\t", '|', ':', ' ', '~'];
$counts = [];
foreach ($potentialDelimiters as $delimiter) {
$counts[$delimiter] = [];
@ -258,11 +258,8 @@ class Csv extends BaseReader
$line = preg_replace('/(' . $enclosure . '.*' . $enclosure . ')/U', '', $line);
// See if we have any enclosures left in the line
$matches = [];
preg_match('/(' . $enclosure . ')/', $line, $matches);
// if we still have an enclosure then we need to read the next line as well
if (count($matches) > 0) {
if (preg_match('/(' . $enclosure . ')/', $line) > 0) {
$line = $this->getNextLine($line);
}