possibilité de skip les premières lignes
This commit is contained in:
parent
a44da62b94
commit
9cf7ac908f
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user