[ 
https://issues.apache.org/jira/browse/CSV-112?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13989018#comment-13989018
 ] 

Benedikt Ritter commented on CSV-112:
-------------------------------------

The problem is, that we provide a key based access to the values of a 
{{CSVRecord}} using the {{get(String)}} method. How should that method behave 
if there are duplicate column names?

> HeaderMap inconsistent when duplicate columns names
> ---------------------------------------------------
>
>                 Key: CSV-112
>                 URL: https://issues.apache.org/jira/browse/CSV-112
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Parser
>    Affects Versions: 1.0
>            Reporter: Romain Gossé
>              Labels: headers, parsing
>
> Given a parser format for csv files with a header line:
> {code}
> CSVFormat myFormat = 
> CSVFormat.RFC4180.withDelimiter(",").withQuoteChar('"').withQuotePolicy(Quote.MINIMAL)
>                               
> .withIgnoreSurroundingSpaces(true).withHeader().withSkipHeaderRecord(true);
> {code}
> And given a file with duplicate header names:
>  
> Col1,Col2,Col2,Col3,Col4
> 1,2,3,4,5
> 4,5,6,7,8 
> The HeaderMap returned by the parser misses an entry because of the Column 
> name being used as a key, leading to wrong behavior when we rely on it.
> If this is not supposed to happen in the file regarding the CSV format, at 
> least this should raise an error. If not we should come up with a more clever 
> way to store and access the headers.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to