You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Steffen Zschaler (JIRA)" <ji...@apache.org> on 2016/06/14 13:21:07 UTC
[jira] [Commented] (CSV-164) Support duplicate header names
[ https://issues.apache.org/jira/browse/CSV-164?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15329481#comment-15329481 ]
Steffen Zschaler commented on CSV-164:
--------------------------------------
I have a similar issue, specifically where the duplicate headers are empty headers. So, for example:
{code}
A,B,,C,,D
1,2,,3,,4
{code}
The empty columns here have been inserted for readability.
I need to do some processing over the file, removing some columns and doing some updates to other places, and then write out the modified CSV file again. Ideally, I would keep the empty columns so that readability is maintained. I also need to keep the header names from the original file. Finally, I have no _ad hoc_ information about how many columns there are in total (beyond a number of standard columns at the left of the file), so cannot easily predefine an artificial header either.
Currently, Commons CSV cannot handle this because it only keeps track of the last empty column. For this specific use case, I think there is a solution that is non-API breaking by providing additional functionality to get a list of all columns with empty headers if empty headers are allowed (which can be flagged already). Optionally, we could also stop putting empty headers into the header map, but this may break some users.
I'm going to have a go at implementing this in a commons-csv fork anyway, as I need it for my current project. Is there an interest in having this contributed back to the main code and if so, should I open a separate issue for it or reference it to this issue?
> Support duplicate header names
> ------------------------------
>
> Key: CSV-164
> URL: https://issues.apache.org/jira/browse/CSV-164
> Project: Commons CSV
> Issue Type: Bug
> Affects Versions: 1.2
> 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)