CsvReader
class CsvReader implements CountableReaderInterface, SeekableIterator
Class CsvReader
Constants
| DUPLICATE_HEADERS_INCREMENT |
|
| DUPLICATE_HEADERS_MERGE |
|
Properties
| protected string | $tmpFile | File path of folder for temporary saving csv files | |
| protected int | $headerRowNumber | Number of the row that contains the column names | |
| protected SplFileObject | $file | CSV file | |
| protected array | $columnHeaders | Column headers as read from the CSV file | |
| protected int | $headersCount | Number of column headers, stored and re-used for performance | |
| protected int | $count | Total number of rows in the CSV file | |
| protected array | $errors | Faulty CSV rows | |
| protected bool | $strict | Strict parsing - skip any lines mismatching header length | |
| protected int | $duplicateHeadersFlag | How to handle duplicate headers |
Methods
Construct CSV reader
Return the current row as an array
Get column headers
Set column headers
No description
Rewind the file pointer
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
No description
Get the field (column, property) names
Get a row
Get rows that have an invalid number of columns
Does the reader contain any invalid rows?
No description
No description
No description
Destructor
No description
No description
No description
Details
at line 102
__construct(mixed $fileBase64, string $delimiter = ',', string $enclosure = '"', string $escape = '\\')
Construct CSV reader
at line 134
array
current()
Return the current row as an array
If a header row has been set, an associative array will be returned
at line 179
array
getColumnHeaders()
Get column headers
at line 191
CsvReader
setColumnHeaders(array $columnHeaders)
Set column headers
at line 207
CsvReader
setHeaderRowNumber(mixed $rowNumber, null $duplicates = null)
at line 223
rewind()
Rewind the file pointer
If a header row has been set, the pointer is set just below the header row. That way, when you iterate over the rows, that header row is skipped.
at line 234
count()
{@inheritdoc}
at line 250
next()
{@inheritdoc}
at line 258
valid()
{@inheritdoc}
at line 266
key()
{@inheritdoc}
at line 274
seek(int $pointer)
at line 282
array
getFields()
Get the field (column, property) names
at line 294
array
getRow(int $number)
Get a row
at line 306
array
getErrors()
Get rows that have an invalid number of columns
at line 322
bool
hasErrors()
Does the reader contain any invalid rows?
at line 330
bool
isStrict()
at line 340
$this
setStrict(mixed $strict)
at line 357
mixed
convert(CSVManagerInterface $manager, String $locale, array $csvHeaders = array(), array $propertyMappings = array())
at line 383
__destruct()
Destructor