[CSV-239] Add CSVRecord.getHeaderNames and allow duplicate headers#41
Merged
Conversation
* getHeaderNames returns all headers in column order including repeats which are allowed as per RFC 4180 * add CSVFormat.withAllowDuplicateHeaderNames()
* only wrap headerNames with unmodifiableList if non-empty * fix and enhance CSVRecord.toMap javadoc
* fix exception messages
* fix whitespace
* simplify if statement
garydgregory
requested changes
May 22, 2019
* fix indentation * add javadoc to Headers class * rename method to createHeaders * use String.format to build error message * initialize header names List with appropriate size
Contributor
Author
|
Thanks for the review, I've addressed all comments with the latest commit. |
Contributor
Author
|
BTW @garydgregory , would you like me to fix these I would just specify the latest versions explicitly for those plugins. |
Member
|
@davidmoten I do not see these warnings. What command do you run to get these? |
Contributor
Author
|
|
Member
|
Merged. I do not see your warnings. Here is my output: |
Contributor
Author
|
Yeah no problem with the warnings. Not sure how I provoked them! Thanks for the merge. The next obvious question is when will you build a release? |
Member
|
I do not have hard set plans. Maybe sometimes next week. I have to finish
Commons Configuration 2.5 first...
Gary
…On Sat, May 25, 2019, 01:56 Dave Moten ***@***.***> wrote:
Yeah no problem with the warnings. Not sure how I provoked them! Thanks
for the merge. The next obvious question is when will you build a release?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#41?email_source=notifications&email_token=AAJB6N3OTWRQX3Y5NJS6USDPXDIJLA5CNFSM4HOQDIL2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWHECGA#issuecomment-495862040>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJB6N7H3R7UFLGOKNPTQ6TPXDIJLANCNFSM4HOQDILQ>
.
|
Member
|
Would you mind providing another PR that adds Javadocs to the public methods you added in |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
These are the changes:
getHeaderNamesreturns all headers in column order including repeats which are allowed in general as per RFC 4180CSVFormat.withAllowDuplicateHeaderNames().CSVFormat.DEFAULTnow allows duplicate header names because RFC 4190 allows non-unique header names. This is a behavioural change but not a breaking API change anywhere because there is no API contract for it (e.g. javadoc). BecauseCSVFormat.DEFAULTshould reflect RFC 4190 I'd classify this as a bug fix.CSVFormatisSerializablewhich means adding new fields to it (allowDuplicateHeaderNames) is theoretically a breaking change. I propose we allow this minor breaking change and also propose thatCSVFormatdoes not implementSerializablein 2.xCSVRecord.toMapjavadocCSVParserwhere an IAE is thrown with a message about duplicate headers when the problem was actually a missing header nameQuestion:
Not addressed:
CSVRecord.toMapreturned a Map whose entries are iterable in column order but this involves quite a bit of rework so will leave for another PR (probably for 2.x).CSVRecord.get(String)should ideally throw when two columns with that header name existNotes for 2.x:
CSVFormat.withAllowMissingColumnNamesshould beCSVFormat.withAllowMissingHeaderNamesSerializablefromCSVFormatCSVFormat.withIgnoreHeaderCasecreates problems and lacks flexibility. I'd suggestCSVRecord.getIgnoreCase(int)instead