Class \avadim\FastExcelReader\Csv\CsvReader
On this page
- __construct()
- Parameters
- close()
- Parameters
- defaultErrorHandler()
- Parameters
- fromCol()
- Parameters
- fromRow()
- Parameters
- getCsvField()
- Parameters
- getCsvLine()
- Parameters
- getLineNo()
- Parameters
- getOptions()
- Parameters
- nextRawRow()
- Parameters
- nextRow()
- Parameters
- onError()
- Parameters
- readRows()
- Parameters
- rewind()
- Parameters
- setBufferSize()
- Parameters
- withHeader()
- Parameters
- __construct() – CsvReader constructor
- close()
- defaultErrorHandler()
- fromCol()
- fromRow()
- getCsvField() – Get next field from CSV file
- getCsvLine() – Get line from CSV file as array of fields (null - empty field, false - EOF)
- getLineNo() – Physical line number of the row last returned by getCsvLine()/nextRawRow()
- getOptions()
- nextRawRow() – Read the next physical row of fields, low level
- nextRow()
- onError()
- readRows() – Read rows and return as 2D array
- rewind()
- setBufferSize()
- withHeader() – Enables header mode
__construct()
public function __construct(string $file, $options)
CsvReader constructor
Parameters
string $fileCsvOptions|array|null $options
close()
public function close()
Parameters
None
defaultErrorHandler()
public function defaultErrorHandler(int $code, string $error, string $line,
int $lineNo, int $colNo)
Parameters
int $codestring $errorstring $lineint $lineNoint $colNo
fromCol()
public function fromCol(int $colNum): CsvReader
Parameters
int $colNum
fromRow()
public function fromRow(int $rowNum): CsvReader
Parameters
int $rowNum
getCsvField()
public function getCsvField(): ?string
Get next field from CSV file
Parameters
None
getCsvLine()
public function getCsvLine(): array|null|false
Get line from CSV file as array of fields (null - empty field, false - EOF)
Parameters
None
getLineNo()
public function getLineNo(): int
Physical line number of the row last returned by getCsvLine()/nextRawRow()
One based, and unaffected by skipping: empty and comment lines advance ittoo, so it matches the row addressing the sheet layer expects.
Parameters
None
getOptions()
public function getOptions(): CsvOptions
Parameters
None
nextRawRow()
public function nextRawRow(): array|false
Read the next physical row of fields, low level
Honours skip-empty-lines and the comment prefix, and returns the raw fieldarray with no column-key or result-mode transformation - that belongs tothe sheet/read-area layer. Returns FALSE at EOF. This is what CsvSheetdrives its rawRows() from, so that the whole read API can be shared withthe XLSX and XLS backends instead of duplicated.
Parameters
None
nextRow()
public function nextRow($columnKeys, ?int $resultMode = null,
?int $rowLimit = 0): ?Generator
Parameters
array|bool|int|null $columnKeysint|null $resultModeint|null $rowLimit
onError()
public function onError(?callable $handler): CsvReader
Parameters
$handler
readRows()
public function readRows($columnKeys, ?int $resultMode = null): array
Read rows and return as 2D array
Parameters
array|bool|int|null $columnKeysint|null $resultMode
rewind()
public function rewind()
Parameters
None
setBufferSize()
public function setBufferSize(int $size): CsvReader
Parameters
int $size
withHeader()
public function withHeader(?array $columnNames = null): CsvReader
Enables header mode
Treats the first row of the CSV file as a header row and returns subsequentrows as associative arrays keyed by column names
Parameters
$columnNames