mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
@@ -1261,7 +1261,7 @@ class Csv {
|
||||
}
|
||||
}
|
||||
|
||||
if ($equal) {
|
||||
if ($equal || $depth === 1) {
|
||||
$match = $almost ? 2 : 1;
|
||||
$pref = strpos($preferred, $char);
|
||||
$pref = ($pref !== false) ? str_pad($pref, 3, '0', STR_PAD_LEFT) : '999';
|
||||
|
||||
1
tests/example_files/single_row.csv
Normal file
1
tests/example_files/single_row.csv
Normal file
@@ -0,0 +1 @@
|
||||
C1,C2,C3
|
||||
|
@@ -121,6 +121,15 @@ class ParseTest extends TestCase {
|
||||
self::assertEquals($expected, $this->csv->data);
|
||||
}
|
||||
|
||||
public function testSingleRow() {
|
||||
$this->csv->auto(__DIR__ . '/../example_files/single_row.csv');
|
||||
self::assertEquals([], $this->csv->data, 'Single row is detected as header');
|
||||
$this->csv->heading = false;
|
||||
$this->csv->auto(__DIR__ . '/../example_files/single_row.csv');
|
||||
$expected = [['C1', 'C2', 'C3']];
|
||||
self::assertEquals($expected, $this->csv->data);
|
||||
}
|
||||
|
||||
public function testMatomoData() {
|
||||
// Matomo (Piwik) export cannot be read with
|
||||
$this->csv->use_mb_convert_encoding = true;
|
||||
|
||||
Reference in New Issue
Block a user