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

Sergei Lebedev commented on CSV-120:
------------------------------------

Thanks!

> CSVFormat#withHeader doesn't work with CSVPrinter
> -------------------------------------------------
>
>                 Key: CSV-120
>                 URL: https://issues.apache.org/jira/browse/CSV-120
>             Project: Commons CSV
>          Issue Type: Bug
>            Reporter: Sergei Lebedev
>            Priority: Minor
>             Fix For: 1.0
>
>
> In the current version 
> [CSVFormat#withHeader|https://commons.apache.org/proper/commons-csv/apidocs/org/apache/commons/csv/CSVFormat.html#withHeader(java.lang.String...)]
>  is only used by CSVParser. It would be nice if CSVPrinter also supported it. 
> Ideally, the following line of code
> {code:java}
> CSVPrinter csvPrinter
>   = CSVFormat.TDF
>     .withHeader("x")
>     .print(Files.newBufferedWriter(Paths.get("data.csv")));
> csvPrinter.printRecord(42);
> csvPrinter.close();
> {code}
> should produce
> {code}
> x
> 42
> {code}
> If you're alright with the idea of automatically inserting headers, I can 
> attach a patch.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to