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

Romain Manni-Bucau commented on CSV-164:
----------------------------------------

This is what I proposed early: if you do get("duplicatedColumnName") then you 
should fail but get("uniqueColumnName") should still work. Doesnt remove the 
access (parse) feature since you can still access it by index.

Typically in batchee mapping we have a thin layer on top of [csv] where you can 
map CSV on an object either by index or name. If you use name then you define 
header names but index access is priviledged over name access which makes this 
case pretty smooth: in 
https://github.com/apache/incubator-batchee/blob/master/extensions/commons-csv/src/main/java/org/apache/batchee/csv/mapper/DefaultMapper.java#L89
 the values of fieldByPosition and fieldByName are unique (ie fieldByName 
doesnt have any duplicate with fieldByPosition) to guaratee all of this to work.

The access by header name is a nice API most of the time but not the way CSV 
really works (column index by definition) so I like this API but it has some 
limits we hit with this issue. 

> Support duplicate header names
> ------------------------------
>
>                 Key: CSV-164
>                 URL: https://issues.apache.org/jira/browse/CSV-164
>             Project: Commons CSV
>          Issue Type: Bug
>            Reporter: Romain Manni-Bucau
>
> nothing prevents a CSV to have the same time the same header name so 
> validation at the end of org.apache.commons.csv.CSVFormat#validate should 
> likely disappear or should support a flag to disable it



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to