We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
SPLFileObject
seek
1 parent 7357615 commit ff392feCopy full SHA for ff392fe
1 file changed
src/Migration/Sources/CSV.php
@@ -65,20 +65,12 @@ public function report(array $resources = []): array
65
$file = new \SplFileObject($this->filePath, 'r');
66
$file->setFlags(\SplFileObject::READ_CSV | \SplFileObject::SKIP_EMPTY);
67
68
- if (! $file->eof()) {
69
- $file->fgetcsv();
70
- }
71
-
72
- $rowCount = 0;
73
- while (! $file->eof()) {
74
- $row = $file->fgetcsv();
75
76
- // check for blank lines
77
- if ($row === [null] || $row === false) {
78
- continue;
79
+ $file->seek(PHP_INT_MAX);
+ $rowCount = $file->key();
80
81
- $rowCount++;
+ // Subtract to exclude header
+ if ($rowCount > 0) {
+ $rowCount--;
82
}
83
84
$report[Resource::TYPE_DOCUMENT] = $rowCount;
0 commit comments