$stream_filter_mode
$stream_filter_mode : integer
The stream filter mode (read or write).
A class to parse and read records from a CSV document.
$document : \SplFileObject|\League\Csv\Stream
The CSV document.
None found |
output(\League\Csv\string $filename = null) : integer
Outputs all data on the CSV file.
\League\Csv\string | $filename |
Returns the number of characters read from the handle and passed through to the output.
None found |
setDelimiter(\League\Csv\string $delimiter) : static
Sets the field delimiter.
\League\Csv\string | $delimiter |
If the Csv control character is not one character only.
None found |
setEnclosure(\League\Csv\string $enclosure) : static
Sets the field enclosure.
\League\Csv\string | $enclosure |
If the Csv control character is not one character only.
None found |
setEscape(\League\Csv\string $escape) : static
Sets the field escape character.
\League\Csv\string | $escape |
If the Csv control character is not one character only.
None found |
None found |
None found |
setOutputBOM(\League\Csv\string $str) : static
Sets the BOM sequence to prepend the CSV on output.
\League\Csv\string | $str |
None found |
addStreamFilter(\League\Csv\string $filtername, null|mixed $params = null) : static
append a stream filter.
\League\Csv\string | $filtername | |
null|mixed | $params |
If the stream filter API can not be used
None found |
getHeaderOffset() : integer|null
Returns the header offset.
If no CSV header offset is set this method MUST return null
None found |
getHeader() : array<mixed,string>
Returns the CSV record used as header.
The returned header is represented as an array of string values
None found |
None found |
None found |
None found |
None found |
getRecords(array<mixed,string> $header = array())
Returns the CSV records as an iterator object.
Each CSV record is represented as a simple array containing strings or null values.
If the CSV document has a header record then each record is combined to the header record and the header record is removed from the iterator.
If the CSV document is inconsistent. Missing record fields are filled with null values while extra record fields are strip from the returned object.
array<mixed,string> | $header | an optional header to use instead of the CSV document header |
None found |
setHeaderOffset(integer|null $offset) : static
Selects the record to be used as the CSV header.
Because the header is represented as an array, to be valid a header MUST contain only unique string value.
integer|null | $offset | the header record offset |
if the offset is a negative integer
None found |
None found |
None found |
isEmptyRecordsIncluded()
Tells whether empty records are skipped by the instance.
None found |
fetchOne(integer $nth_record) : array
Returns a single record from the CSV
integer | $nth_record |
None found |
fetchColumn(string|integer $column_index) : \Generator
Returns the next value from a single CSV record field
string|integer | $column_index |
None found |
fetchPairs(string|integer $offset_index, string|integer $value_index = 1) : \Generator
Fetches the next key-value pairs from the CSV document
string|integer | $offset_index | |
string|integer | $value_index |
None found |
__construct(\SplFileObject|\League\Csv\Stream $document)
New instance.
\SplFileObject|\League\Csv\Stream | $document | The CSV Object instance |
None found |
None found |
sendHeaders(\League\Csv\string $filename)
Send the CSV headers.
Adapted from Symfony\Component\HttpFoundation\ResponseHeaderBag::makeDisposition
\League\Csv\string | $filename |
if the submitted header is invalid according to RFC 6266
None found |
setHeader(\League\Csv\int $offset) : array<mixed,string>
Determine the CSV record header.
\League\Csv\int | $offset |
If the header offset is set and no record is found or is the empty array
None found |
seekRow(\League\Csv\int $offset) : array|false
Returns the row at a given offset.
\League\Csv\int | $offset |
None found |
None found |
removeBOM(array<mixed,string> $record, \League\Csv\int $bom_length, \League\Csv\string $enclosure) : array<mixed,string>
Strip the BOM sequence from a record.
array<mixed,string> | $record | |
\League\Csv\int | $bom_length | |
\League\Csv\string | $enclosure |
None found |
computeHeader(array<mixed,string> $header) : array<mixed,string>
Returns the header to be used for iteration.
array<mixed,string> | $header |
If the header contains non unique column name
None found |
combineHeader(\Iterator $iterator, array<mixed,string> $header)
Combine the CSV header to each record if present.
\Iterator | $iterator | |
array<mixed,string> | $header |
None found |
stripBOM(\Iterator $iterator, \League\Csv\string $bom)
Strip the BOM sequence from the returned records if necessary.
\Iterator | $iterator | |
\League\Csv\string | $bom |
None found |