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