commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CSV-120) CSVFormat#withHeader doesn't work with CSVPrinter
Date Mon, 09 Jun 2014 22:17:01 GMT

     [ https://issues.apache.org/jira/browse/CSV-120?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Gary Gregory updated CSV-120:
-----------------------------

    Summary: CSVFormat#withHeader doesn't work with CSVPrinter  (was: 'withHeader' doesn't
work for 'CSVPrinter')

> 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
>
> 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)

Mime
View raw message