Tsv
class Tsv extends Reader (View source)
Constants
| MODE_COLUMN |
|
| SKIP_BLANK |
|
| SKIP_HEADER |
|
| STRICT |
|
Properties
| protected | $separator | from Reader | |
| protected | $separators | ||
| protected | $stream | from Reader |
Methods
Open file with tab-separated values
Set the behavior of the fetch() method, and returns the previously defined flags.
Set a custom filter that can be used to skip specific rows by returning false
in the callback, or simply to modify the values received by reference.
Set the maximum number of rows returned and skips a certain number of rows before starting to return rows.
Parse header and lines
Details
__construct(string $path)
Open file with tab-separated values
in
Reader at line 70
__destruct()
No description
in
Reader at line 82
array<int, string>
getHeaders()
Get headers from file
in
Reader at line 93
resource
getStream()
Get file pointer resource
refresh()
Rewind the position of file pointer and refresh headers
setChunk(int|null $length)
Set maximum line length
setDataTransferObject(string|null $dto)
Set Data Transfer Object class
Note: To ensure the key format, use setFilter() method.
setEndOfLine(string $eol)
Set end-of-line
int
setFlags(int $flags)
Set the behavior of the fetch() method, and returns the previously defined flags.
callable
setFilter(callable $filter)
Set a custom filter that can be used to skip specific rows by returning false
in the callback, or simply to modify the values received by reference.
Note: For headers, the filter is only used to modify the values. Note: When defining a callback, the previous callback will be returned.
E.g:
$handle->setFilter(function (array &$fields, $index) {
if ($index === 0) {
// Convert header
$fields = str_to_snake_case($fields);
} else {
// Convert rows
$field = array_map('stripcslashes', $field);
}
});
setLimit(int $count, int $offset = 0)
Set the maximum number of rows returned and skips a certain number of rows before starting to return rows.
Note: If this method is not used, it will be limited to 1000 rows.
array<int, string>|array<string, string>|false
fetch()
Fetch a row from file pointer
Converter
converter()
Get a Converter instance.
protected array<int, string>|false
parse(string $separator, string $entry)
Parse header and lines