$document
$document : \SplFileObject|\League\Csv\Stream
A Polyfill to PHP's SplFileObject to enable parsing the CSV document without taking into account the escape character.
$document : \SplFileObject|\League\Csv\Stream
parse(\SplFileObject|\League\Csv\Stream $document) : \Generator|array<mixed,array>
Converts the document into a CSV record iterator.
In PHP7.4+ you'll be able to do
$file = new SplFileObject('/path/to/file.csv', 'r');
$file->setFlags(SplFileObject::READ_CSV | SplFileObject::READ_AHEAD | SplFileObject::SKIP_EMPTY);
$file->setCsvControl($delimiter, $enclosure, '');
foreach ($file as $record) {
//$record escape mechanism is blocked by the empty string
}
In PHP7.3- you can do
$file = new SplFileObject('/path/to/file.csv', 'r');
$it = EmptyEscapeParser::parse($file); //parsing will be done while ignoring the escape character value.
foreach ($it as $record) {
//fgetcsv is not directly use hence the escape char is not taken into account
}
Each record array contains strings elements.
\SplFileObject|\League\Csv\Stream | $document |
filterDocument(\SplFileObject|\League\Csv\Stream $document) : \SplFileObject|\League\Csv\Stream
Filters the submitted document.
\SplFileObject|\League\Csv\Stream | $document |
extractEnclosedFieldContent() : string|null
Extracts the content from a field with enclosure.