Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4174: Allow to activate trailing delimiter for CSV parser #4175

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from

Conversation

stefan-korn
Copy link
Contributor

fixes #4174

  • Test coverage exists
  • Documentation exists

QA Steps

  • use a csv file with a trailing delimiter and note that the import will fail
  • change the trailing_delimiter setting via EventSubscriber to true and note that the import (drush dkan:datastore:reimport) will now work

Copy link
Member

@dafeder dafeder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a lot of sense to implement. You probably know what I'm going to say next - are you able to provide test coverage for it?

];

$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'])) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it not be a little cleaner to expect this to be a bool and therefore have a tighter conditional for it?

Suggested change
if (!empty($parserConfiguration['trailing_delimiter'])) {
if ($parserConfiguration['trailing_delimiter'] === TRUE) {

@dafeder dafeder self-assigned this Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to activate trailing delimiter for CSV parser
3 participants