From 9cf7ac908f950e305f38ab0b9c2dea284d02c997 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Mon, 16 Jun 2025 23:15:02 +0400 Subject: [PATCH] =?UTF-8?q?possibilit=C3=A9=20de=20skip=20les=20premi?= =?UTF-8?q?=C3=A8res=20lignes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/src/file/tab/AbstractReader.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/php/src/file/tab/AbstractReader.php b/php/src/file/tab/AbstractReader.php index 6418235..8bffb47 100644 --- a/php/src/file/tab/AbstractReader.php +++ b/php/src/file/tab/AbstractReader.php @@ -52,6 +52,7 @@ abstract class AbstractReader implements IReader { $this->headers = $params["headers"] ?? static::HEADERS; $this->useHeaders = $params["use_headers"] ?? static::USE_HEADERS; $this->input = $params["input"] ?? static::INPUT; + $this->skip = $params["skip"] ?? 0; $this->trim = boolval($params["trim"] ?? static::TRIM); $this->emptyAsNull = boolval($params["empty_as_null"] ?? static::EMPTY_AS_NULL); $this->parseNone = boolval($params["parse_none"] ?? static::PARSE_NONE); @@ -67,6 +68,8 @@ abstract class AbstractReader implements IReader { protected $input; + protected int $skip; + protected bool $trim; protected bool $emptyAsNull; @@ -81,15 +84,16 @@ abstract class AbstractReader implements IReader { protected function cookRow(array &$row): bool { if (!$this->useHeaders) return true; - if ($this->isrc == 0) { + if ($this->skip > 0) { + $this->skip--; + return false; + } + if ($this->headers === null) { # ligne d'en-tĂȘte - $headers = $this->headers; - if ($headers === null) { - if ($this->schema === null) $headers = null; - else $headers = array_keys($this->schema); - if ($headers === null) $headers = $row; - $this->headers = $headers; - } + if ($this->schema === null) $headers = null; + else $headers = array_keys($this->schema); + if ($headers === null) $headers = $row; + $this->headers = $headers; return false; } A::ensure_size($row, count($this->headers));