SethFalco commented on pull request #114:
URL: https://github.com/apache/commons-csv/pull/114#issuecomment-876858602
I didn't see it documented, figured the easiest way to find out would be to
just test it.
It currently uses the last column with the given name.
> What happens/should happen for each enum value when you call
CSVRecord.get(String).
| A | A
|---|---
| 1 | 2
| 3 | 4
```java
List<CSVRecord> records = parser.getRecords();
for (CSVRecord record : records)
System.out.println(record.get("A"));
// 2
// 4
```
> What happens/should happen for each enum value when you call
CSVRecord.toMap().
| A | A | B | B
|---|---|---|---
| 1 | 2 | 5 | 6
| 3 | 4 | 7 | 8
```java
List<CSVRecord> records = parser.getRecords();
for (CSVRecord record : records) {
Map<String, String> map = record.toMap();
System.out.println(map);
}
// {A=2, B=6}
// {A=4, B=8}
```
I think we could add a docstring on `CSVRecord#get` and `CSVRecord#toMap` to
clarify this.
We could also add something on `CSVFormat#setDuplicateHeaderMode`?
It might be a good idea to add test cases to cover this scenario, if it'll
become documented behavior.
Mind if I do this in a separate PR?
I'd say it counts as a separate change from this one, so it'll keep things
tidier.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]