You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/07/03 08:50:00 UTC

[jira] [Work logged] (CSV-247) A single empty header is allowed when not allowing empty column headers.

     [ https://issues.apache.org/jira/browse/CSV-247?focusedWorklogId=271471&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-271471 ]

ASF GitHub Bot logged work on CSV-247:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Jul/19 08:49
            Start Date: 03/Jul/19 08:49
    Worklog Time Spent: 10m 
      Work Description: aherbert commented on pull request #47: CSV-247: CSVParser to check an empty header before checking duplicates.
URL: https://github.com/apache/commons-csv/pull/47
 
 
   This rearranges the logic of checking for empty column headers before checking for duplicates.
   
   I've left the rest of the logic alone. The implication is that it will always allow a duplicate header if the header is empty irrespective of whether duplicates are not allowed. So you can configure the parser to not allow duplicates but allow missing headers and then it skips the fact that each missing header is a duplicate. If documented this in the code.
   
   I also note that the header is checked for a duplicate without trim but the empty header check uses trim. This is contradictory but perhaps a user does want to have headers `"A"," A "," A"`. Any proper CSV header would not whitespace pad headers so I'll leave this until someone reports it as a problem. 
   
   The fix found that the existing test `CSVParserTest.testHeaderMissing()` did not set the AllowMissingColumnNames property. If this test is to work with a missing header then it needs that setting.
   
   I also updated the tests of missing headers which use 5 columns to have 5 entries in the record. Previously it was 4 which is not correct.
   
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 271471)
            Time Spent: 10m
    Remaining Estimate: 0h

> A single empty header is allowed when not allowing empty column headers.
> ------------------------------------------------------------------------
>
>                 Key: CSV-247
>                 URL: https://issues.apache.org/jira/browse/CSV-247
>             Project: Commons CSV
>          Issue Type: Bug
>    Affects Versions: 1.7
>            Reporter: Alex D Herbert
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> If the settings are not allowing empty columns headers you can currently use a single empty header. This is because column headers are only checked for empty when they are duplicates. So it is the second empty header (the first duplicate) that raises an error. This test should pass but does not:
> {code:java}
> @Test(expected = IllegalArgumentException.class)
> public void testHeadersMissingOneColumnException() throws Exception {
>     final Reader in = new StringReader("a,,c,d\n1,2,3,4\nx,y,z,zz");    CSVFormat.DEFAULT.withHeader().parse(in).iterator(); 
> }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)