[
https://issues.apache.org/jira/browse/CSV-127?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14113331#comment-14113331
]
Gary Gregory commented on CSV-127:
----------------------------------
Note that this works:
{code:java}
@Test
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)
.getHeaderMap();
assertNotNull("Unable to find value for named column", header.get("a"));
}
{code}
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: https://issues.apache.org/jira/browse/CSV-127
> 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
(v6.2#6252)