commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <>
Subject [jira] [Commented] (CSV-127) Ignore Empty Lines doesn't ignore empty first line
Date Thu, 28 Aug 2014 04:41:57 GMT


Gary Gregory commented on CSV-127:

Note that this works:

    public void testFirstLineEmptyWithHeader() throws Exception {
        // Test that an empty line is skipped before setting the header
        final Reader in = new StringReader("\na,b,c\n1,2,3\nx,y,z");
        final Map<String, Integer> header = CSVFormat.DEFAULT.withHeader().withIgnoreEmptyLines().parse(in)
        assertNotNull("Unable to find value for named column", header.get("a"));

The first line is {{empty}}, just an EOR (=EOL) char.

In your example, you line is a {{blank}} line, a space followed by an EOR.

You would think that {{withIgnoreEmptyLines()}} should handle that in {{Lexer.nextToken(Token)}}
... but it does not, probably because it is the first line.

> Ignore Empty Lines doesn't ignore empty first line
> --------------------------------------------------
>                 Key: CSV-127
>                 URL:
>             Project: Commons CSV
>          Issue Type: Bug
>    Affects Versions: 1.0
>            Reporter: Cody Lerum
>         Attachments: csv-127.patch
> If parsing a file which has an empty first line and then a header row the empty first
line is treated as the header row.
> Parser created like
> {code}
> CSVParser csvParser = new CSVParser(reader, CSVFormat.DEFAULT.withHeader().withIgnoreSurroundingSpaces(true));
> {code}

This message was sent by Atlassian JIRA

View raw message