From 3123b731794125bbfaa1e408ce0cab6746d8a0b2 Mon Sep 17 00:00:00 2001 From: Stefan Korn Date: Thu, 2 May 2024 09:17:44 +0200 Subject: [PATCH 1/2] #4174: Allow to activate trailing delimiter for CSV parser --- modules/datastore/src/Service/ImportService.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/datastore/src/Service/ImportService.php b/modules/datastore/src/Service/ImportService.php index a89c097c18..ecfb5f58dc 100644 --- a/modules/datastore/src/Service/ImportService.php +++ b/modules/datastore/src/Service/ImportService.php @@ -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; } From 7af75bf3256cce878f5afc3da9c38c319c165cea Mon Sep 17 00:00:00 2001 From: Stefan Korn Date: Fri, 3 May 2024 07:20:15 +0200 Subject: [PATCH 2/2] #4174: Allow to activate trailing delimiter for CSV parser --- modules/datastore/src/Service/ImportService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/datastore/src/Service/ImportService.php b/modules/datastore/src/Service/ImportService.php index ecfb5f58dc..00a8a1aeb1 100644 --- a/modules/datastore/src/Service/ImportService.php +++ b/modules/datastore/src/Service/ImportService.php @@ -208,7 +208,7 @@ private function getNonRecordingParser(string $delimiter) : Csv { $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'])) { + if ($parserConfiguration['trailing_delimiter'] === TRUE) { $parser->activateTrailingDelimiter(); } $parser->machine->stopRecording();