-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Introduce commentCharacter
property in @Csv{File}Source
#5031
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
Draft
vdmitrienko
wants to merge
2
commits into
junit-team:main
Choose a base branch
from
vdmitrienko:5028-introduce-comment-character
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m concerned that using
CsvSource#value
results in an exception withdelimiter = '#'
, even though the comment strategy forvalue
isNONE
, meaning that all comments ignored:@osiegmar, could we have FastCSV ignore a
commentCharacter
that duplicates thefieldSeparator
orquoteCharacter
whenCommentStrategy.NONE
is used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vdmitrienko I think so, yes! I can take a look at it tomorrow or the day after and let you know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is possibly a dumb question and maybe not the right place to discuss this, but I'm going to ask anyway... 🙂
@osiegmar Even if
CommentStrategy
isn'tNONE
, couldn't FastCSV allow using the same char ascommentCharacter
andquoteCharacter
since lines must start withcommentCharacter
in order to be treated as comments?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a dumb question at all, because... I was thinking the exact same thing. 🤓
Is there a technical reason that FastCSV does not allow the comment character and delimiter (field separator) to be the same?
Or is that rather a potential enhancement for FastCSV to support that like the Univocity parser did?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supporting the same character for both field separator and comment character can lead to ambiguity.
Consider content like this:
Now, imagine the same content, but using
#
as both the field separator and the comment character:The meaning in the last line is ambiguous. Is it a comment or a record with an empty first field and "bar" as the second field?
For the sake of clarity and reliability, FastCSV does not allow to use the same character for both purposes at the same time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the example, @osiegmar.
I agree that the latter is ambiguous, even if it was supported previously in JUnit Jupiter.
And I admit: I personally find it a bit odd to use the same character for both (even if it previously worked).
So, perhaps it's best to:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vdmitrienko I’ve created the branch here: https://github.com/osiegmar/FastCSV/tree/feat/ignore-same-comment-char. Like you suggested, the comment character is ignored for
CommentStrategy.NONE
.If everything looks good on your end, I can go ahead and release it quickly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@osiegmar, I've just checked the changes you implemented, they work exactly as expected. Thank you!
Could you, please, proceed to releasing them?
In the meantime, I'll update the PR accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vdmitrienko Awesome! FastCSV 4.1.0 has been released.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@osiegmar Thanks for the super quick turnaround!
Updated in #5046