Skip to content

Commit f137078

Browse files
committed
Fixing bug in ExcelExtractor skipping first row when no headers needed
1 parent c431232 commit f137078

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

src/adapter/etl-adapter-excel/src/Flow/ETL/Adapter/Excel/ExcelExtractor.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ public function extract(FlowContext $context) : \Generator
5252
// Offset must be a positive number
5353
$offset = $this->offset ?? 1;
5454

55-
if (!$this->withHeader) {
56-
$offset++;
57-
}
58-
5955
foreach ($context->streams()->list($this->path, $this->filter()) as $stream) {
6056
foreach ($this->extractRows($stream, $headers, $offset) as $row) {
6157
// Ensure $row is an array before passing to array_to_rows

src/adapter/etl-adapter-excel/tests/Flow/ETL/Adapter/Excel/Tests/Integration/ExcelExtractorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function test_extract_excel_file_with_offset_without_header(string $fixtu
113113
->fetch()
114114
->toArray();
115115

116-
self::assertCount(6, $rows);
116+
self::assertCount(7, $rows);
117117

118118
foreach ($rows as $row) {
119119
self::assertSame(['e00', 'e01', 'e02'], \array_keys($row));
@@ -166,7 +166,7 @@ public function test_extract_excel_file_without_header(string $fixtureName) : vo
166166
->fetch()
167167
->toArray();
168168

169-
self::assertCount(10, $rows);
169+
self::assertCount(11, $rows);
170170

171171
foreach ($rows as $row) {
172172
self::assertSame(['e00', 'e01', 'e02'], \array_keys($row));

src/adapter/etl-adapter-excel/tests/Flow/ETL/Adapter/Excel/Tests/Integration/ExcelLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ public function test_round_trip_without_header(ExcelWriter $writer, string $exte
380380
->run();
381381

382382
$rows = df()
383-
->read(from_excel($outputPath))
383+
->read(from_excel($outputPath)->withHeader(false))
384384
->fetch()
385385
->toArray();
386386

0 commit comments

Comments
 (0)