CSVParser JavaDoc should be about using the CSVParser and not how to customize CSVFormats. Customizing CSVFormats is subject of CSVFormat JavaDoc.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1522836 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benedikt Ritter 2013-09-13 09:44:55 +00:00
parent ffb63750e2
commit 8a5f777a0e
1 changed files with 27 additions and 20 deletions

View File

@ -41,6 +41,8 @@ import java.util.NoSuchElementException;
* Because CSV appears in many different dialects, the parser supports many formats by allowing the * Because CSV appears in many different dialects, the parser supports many formats by allowing the
* specification of a {@link CSVFormat}. * specification of a {@link CSVFormat}.
* *
* The parser works record wise. It is not possible to go back, once a record has been parsed from the input stream.
*
* <h4>Creating instances</h4> * <h4>Creating instances</h4>
* There are several static factory methods that can be used to create instances for various types of resources: * There are several static factory methods that can be used to create instances for various types of resources:
* <p> * <p>
@ -56,33 +58,38 @@ import java.util.NoSuchElementException;
* *
* <h4>Parsing record wise</h4> * <h4>Parsing record wise</h4>
* <p> * <p>
* To parse a CSV input with tabs as separators, '"' (double-quote) as an optional value encapsulator, and comments * To parse a CSV input from a file, you write:
* starting with '#', you write:
* </p> * </p>
* *
* <pre> * <pre>
* Reader in = new StringReader(&quot;a\tb\nc\td&quot;); * File csvData = new File(&quot;/path/to/csv&quot;);
* Iterable&lt;CSVRecord&gt; parser = CSVFormat.DEFAULT * CSVParser parser = CSVParser.parse(csvData, CSVFormat.RFC4180);
* .withCommentStart('#') * for (CSVRecord csvRecord : parser) {
* .withDelimiter('\t')
* .withQuoteChar('"').parse(in);
* for (CSVRecord csvRecord : parse) {
* ... * ...
* } * }
* </pre> * </pre>
* *
* <p> * <p>
* To parse CSV input in a given format like Excel, you write: * This will read the parse the contents of the file using the
* <a href="http://tools.ietf.org/html/rfc4180" target="_blank">RFC 4180</a> format.
* </p>
*
* <p>
* To parse CSV input in a format like Excel, you write:
* </p> * </p>
* *
* <pre> * <pre>
* Reader in = new StringReader("a;b\nc;d"); * CSVParser parser = CSVParser.parse(csvData, CSVFormat.EXCEL);
* Iterable&lt;CSVRecord&gt; parser = CSVFormat.EXCEL.parse(in); * for (CSVRecord csvRecord : parser) {
* for (CSVRecord record : parser) {
* ... * ...
* } * }
* </pre> * </pre>
* *
* <p>
* If the predefined formats don't match the format at hands, custom formats can be defined. More information about
* customising CSVFormats is available in {@link CSVFormat CSVFormat JavaDoc}.
* </p>
*
* <h4>Parsing completely into memory</h4> * <h4>Parsing completely into memory</h4>
* <p> * <p>
* You may also get a List of records: * You may also get a List of records: