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));