Skip to content

Commit 8a5f777

Browse files
committed
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
1 parent ffb6375 commit 8a5f777

1 file changed

Lines changed: 20 additions & 13 deletions

File tree

src/main/java/org/apache/commons/csv/CSVParser.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
* Because CSV appears in many different dialects, the parser supports many formats by allowing the
4242
* specification of a {@link CSVFormat}.
4343
*
44+
* The parser works record wise. It is not possible to go back, once a record has been parsed from the input stream.
45+
*
4446
* <h4>Creating instances</h4>
4547
* There are several static factory methods that can be used to create instances for various types of resources:
4648
* <p>
@@ -56,33 +58,38 @@
5658
*
5759
* <h4>Parsing record wise</h4>
5860
* <p>
59-
* To parse a CSV input with tabs as separators, '"' (double-quote) as an optional value encapsulator, and comments
60-
* starting with '#', you write:
61+
* To parse a CSV input from a file, you write:
6162
* </p>
6263
*
6364
* <pre>
64-
* Reader in = new StringReader(&quot;a\tb\nc\td&quot;);
65-
* Iterable&lt;CSVRecord&gt; parser = CSVFormat.DEFAULT
66-
* .withCommentStart('#')
67-
* .withDelimiter('\t')
68-
* .withQuoteChar('"').parse(in);
69-
* for (CSVRecord csvRecord : parse) {
65+
* File csvData = new File(&quot;/path/to/csv&quot;);
66+
* CSVParser parser = CSVParser.parse(csvData, CSVFormat.RFC4180);
67+
* for (CSVRecord csvRecord : parser) {
7068
* ...
71-
* }
69+
* }
7270
* </pre>
7371
*
7472
* <p>
75-
* To parse CSV input in a given format like Excel, you write:
73+
* This will read the parse the contents of the file using the
74+
* <a href="http://tools.ietf.org/html/rfc4180" target="_blank">RFC 4180</a> format.
75+
* </p>
76+
*
77+
* <p>
78+
* To parse CSV input in a format like Excel, you write:
7679
* </p>
7780
*
7881
* <pre>
79-
* Reader in = new StringReader("a;b\nc;d");
80-
* Iterable&lt;CSVRecord&gt; parser = CSVFormat.EXCEL.parse(in);
81-
* for (CSVRecord record : parser) {
82+
* CSVParser parser = CSVParser.parse(csvData, CSVFormat.EXCEL);
83+
* for (CSVRecord csvRecord : parser) {
8284
* ...
8385
* }
8486
* </pre>
8587
*
88+
* <p>
89+
* If the predefined formats don't match the format at hands, custom formats can be defined. More information about
90+
* customising CSVFormats is available in {@link CSVFormat CSVFormat JavaDoc}.
91+
* </p>
92+
*
8693
* <h4>Parsing completely into memory</h4>
8794
* <p>
8895
* You may also get a List of records:

0 commit comments

Comments
 (0)