public function Parser::getCsvById in CSV Importer 8
Get CSV by id.
Parameters
int $id: CSV id.
string $delimiter: CSV delimiter.
Return value
array|null Parsed CSV.
Overrides ParserInterface::getCsvById
1 call to Parser::getCsvById()
- Parser::getCsvFieldsById in src/
Parser.php - Get CSV column (first row).
File
- src/
Parser.php, line 32
Class
- Parser
- Parser manager.
Namespace
Drupal\csv_importerCode
public function getCsvById(int $id, string $delimiter) {
/* @var \Drupal\file\Entity\File $entity */
$entity = $this
->getCsvEntity($id);
$return = [];
if (($csv = fopen($entity->uri
->getString(), 'r')) !== FALSE) {
while (($row = fgetcsv($csv, 0, $delimiter)) !== FALSE) {
$return[] = $row;
}
fclose($csv);
}
return $return;
}