Skip to content

Commit

Permalink
GetDKAN#4174: Allow to activate trailing delimiter for CSV parser
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-korn committed May 2, 2024
1 parent 6061fbe commit 3123b73
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/datastore/src/Service/ImportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,15 @@ private function getNonRecordingParser(string $delimiter) : Csv {
'quote' => '"',
'escape' => "\\",
'record_end' => ["\n", "\r"],
'trailing_delimiter' => FALSE,
];

$parserConfiguration = $this->dispatchEvent(self::EVENT_CONFIGURE_PARSER, $parserConfiguration);

$parser = Csv::getParser($parserConfiguration['delimiter'], $parserConfiguration['quote'], $parserConfiguration['escape'], $parserConfiguration['record_end']);
if (!empty($parserConfiguration['trailing_delimiter'])) {
$parser->activateTrailingDelimiter();
}
$parser->machine->stopRecording();
return $parser;
}
Expand Down

0 comments on commit 3123b73

Please sign in to comment.