254 lines
9.6 KiB
HTML
254 lines
9.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<!-- NewPage -->
|
|
<html lang="en">
|
|
<head>
|
|
<!-- Generated by javadoc -->
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
|
<title>org.apache.commons.csv (Apache Commons CSV 1.7 API)</title>
|
|
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
|
|
<script type="text/javascript" src="../../../../script.js"></script>
|
|
</head>
|
|
<body>
|
|
<script type="text/javascript"><!--
|
|
try {
|
|
if (location.href.indexOf('is-external=true') == -1) {
|
|
parent.document.title="org.apache.commons.csv (Apache Commons CSV 1.7 API)";
|
|
}
|
|
}
|
|
catch(err) {
|
|
}
|
|
//-->
|
|
</script>
|
|
<noscript>
|
|
<div>JavaScript is disabled on your browser.</div>
|
|
</noscript>
|
|
<!-- ========= START OF TOP NAVBAR ======= -->
|
|
<div class="topNav"><a name="navbar.top">
|
|
<!-- -->
|
|
</a>
|
|
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
|
|
<a name="navbar.top.firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li><a href="../../../../org/apache/commons/csv/package-summary.html">Package</a></li>
|
|
<li>Class</li>
|
|
<li><a href="package-use.html">Use</a></li>
|
|
<li><a href="package-tree.html">Tree</a></li>
|
|
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
|
|
<li><a href="../../../../index-all.html">Index</a></li>
|
|
<li><a href="../../../../help-doc.html">Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li>Prev Package</li>
|
|
<li>Next Package</li>
|
|
</ul>
|
|
<ul class="navList">
|
|
<li><a href="../../../../index.html?org/apache/commons/csv/package-summary.html" target="_top">Frames</a></li>
|
|
<li><a href="package-summary.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_top">
|
|
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
|
|
</ul>
|
|
<div>
|
|
<script type="text/javascript"><!--
|
|
allClassesLink = document.getElementById("allclasses_navbar_top");
|
|
if(window==top) {
|
|
allClassesLink.style.display = "block";
|
|
}
|
|
else {
|
|
allClassesLink.style.display = "none";
|
|
}
|
|
//-->
|
|
</script>
|
|
</div>
|
|
<a name="skip.navbar.top">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ========= END OF TOP NAVBAR ========= -->
|
|
<div class="header">
|
|
<h1 title="Package" class="title">Package org.apache.commons.csv</h1>
|
|
<div class="docSummary">
|
|
<div class="block">Apache Commons CSV Format Support.</div>
|
|
</div>
|
|
<p>See: <a href="#package.description">Description</a></p>
|
|
</div>
|
|
<div class="contentContainer">
|
|
<ul class="blockList">
|
|
<li class="blockList">
|
|
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation">
|
|
<caption><span>Class Summary</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Class</th>
|
|
<th class="colLast" scope="col">Description</th>
|
|
</tr>
|
|
<tbody>
|
|
<tr class="altColor">
|
|
<td class="colFirst"><a href="../../../../org/apache/commons/csv/CSVFormat.html" title="class in org.apache.commons.csv">CSVFormat</a></td>
|
|
<td class="colLast">
|
|
<div class="block">Specifies the format of a CSV file and parses input.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor">
|
|
<td class="colFirst"><a href="../../../../org/apache/commons/csv/CSVParser.html" title="class in org.apache.commons.csv">CSVParser</a></td>
|
|
<td class="colLast">
|
|
<div class="block">Parses CSV files according to the specified format.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="altColor">
|
|
<td class="colFirst"><a href="../../../../org/apache/commons/csv/CSVPrinter.html" title="class in org.apache.commons.csv">CSVPrinter</a></td>
|
|
<td class="colLast">
|
|
<div class="block">Prints values in a <a href="../../../../org/apache/commons/csv/CSVFormat.html" title="class in org.apache.commons.csv"><code>CSV format</code></a>.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor">
|
|
<td class="colFirst"><a href="../../../../org/apache/commons/csv/CSVRecord.html" title="class in org.apache.commons.csv">CSVRecord</a></td>
|
|
<td class="colLast">
|
|
<div class="block">A CSV record parsed from a CSV file.</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</li>
|
|
<li class="blockList">
|
|
<table class="typeSummary" border="0" cellpadding="3" cellspacing="0" summary="Enum Summary table, listing enums, and an explanation">
|
|
<caption><span>Enum Summary</span><span class="tabEnd"> </span></caption>
|
|
<tr>
|
|
<th class="colFirst" scope="col">Enum</th>
|
|
<th class="colLast" scope="col">Description</th>
|
|
</tr>
|
|
<tbody>
|
|
<tr class="altColor">
|
|
<td class="colFirst"><a href="../../../../org/apache/commons/csv/CSVFormat.Predefined.html" title="enum in org.apache.commons.csv">CSVFormat.Predefined</a></td>
|
|
<td class="colLast">
|
|
<div class="block">Predefines formats.</div>
|
|
</td>
|
|
</tr>
|
|
<tr class="rowColor">
|
|
<td class="colFirst"><a href="../../../../org/apache/commons/csv/QuoteMode.html" title="enum in org.apache.commons.csv">QuoteMode</a></td>
|
|
<td class="colLast">
|
|
<div class="block">Defines quoting behavior when printing.</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</li>
|
|
</ul>
|
|
<a name="package.description">
|
|
<!-- -->
|
|
</a>
|
|
<h2 title="Package org.apache.commons.csv Description">Package org.apache.commons.csv Description</h2>
|
|
<div class="block">Apache Commons CSV Format Support.
|
|
|
|
<p>CSV are widely used as interfaces to legacy systems or manual data-imports.
|
|
CSV stands for "Comma Separated Values" (or sometimes "Character Separated
|
|
Values"). The CSV data format is defined in
|
|
<a href="http://tools.ietf.org/html/rfc4180" target="_blank">RFC 4180</a>
|
|
but many dialects exist.</p>
|
|
|
|
<p>Common to all file dialects is its basic structure: The CSV data-format
|
|
is record oriented, whereas each record starts on a new textual line. A
|
|
record is build of a list of values. Keep in mind that not all records
|
|
must have an equal number of values:</p>
|
|
<pre>
|
|
csv := records*
|
|
record := values*
|
|
</pre>
|
|
|
|
<p>The following list contains the CSV aspects the Commons CSV parser supports:</p>
|
|
<dl>
|
|
<dt>Separators (for lines)</dt>
|
|
<dd>The record separators are hardcoded and cannot be changed. The must be '\r', '\n' or '\r\n'.</dd>
|
|
|
|
<dt>Delimiter (for values)</dt>
|
|
<dd>The delimiter for values is freely configurable (default ',').</dd>
|
|
|
|
<dt>Comments</dt>
|
|
<dd>Some CSV-dialects support a simple comment syntax. A comment is a record
|
|
which must start with a designated character (the commentStarter). A record
|
|
of this kind is treated as comment and gets removed from the input (default none)</dd>
|
|
|
|
<dt>Encapsulator</dt>
|
|
<dd>Two encapsulator characters (default '"') are used to enclose -> complex values.</dd>
|
|
|
|
<dt>Simple values</dt>
|
|
<dd>A simple value consist of all characters (except the delimiter) until
|
|
(but not including) the next delimiter or a record-terminator. Optionally
|
|
all surrounding whitespaces of a simple value can be ignored (default: true).</dd>
|
|
|
|
<dt>Complex values</dt>
|
|
<dd>Complex values are encapsulated within a pair of the defined encapsulator characters.
|
|
The encapsulator itself must be escaped or doubled when used inside complex values.
|
|
Complex values preserve all kind of formatting (including newlines -> multiline-values)</dd>
|
|
|
|
<dt>Empty line skipping</dt>
|
|
<dd>Optionally empty lines in CSV files can be skipped.
|
|
Otherwise, empty lines will return a record with a single empty value.</dd>
|
|
</dl>
|
|
|
|
<p>In addition to individually defined dialects, two predefined dialects (strict-csv, and excel-csv)
|
|
can be set directly.</p> <!-- TODO fix -->
|
|
|
|
<p>Example usage:</p>
|
|
<blockquote><pre>
|
|
Reader in = new StringReader("a,b,c");
|
|
for (CSVRecord record : CSVFormat.DEFAULT.parse(in)) {
|
|
for (String field : record) {
|
|
System.out.print("\"" + field + "\", ");
|
|
}
|
|
System.out.println();
|
|
}
|
|
</pre></blockquote></div>
|
|
</div>
|
|
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
|
<div class="bottomNav"><a name="navbar.bottom">
|
|
<!-- -->
|
|
</a>
|
|
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
|
|
<a name="navbar.bottom.firstrow">
|
|
<!-- -->
|
|
</a>
|
|
<ul class="navList" title="Navigation">
|
|
<li><a href="../../../../org/apache/commons/csv/package-summary.html">Package</a></li>
|
|
<li>Class</li>
|
|
<li><a href="package-use.html">Use</a></li>
|
|
<li><a href="package-tree.html">Tree</a></li>
|
|
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
|
|
<li><a href="../../../../index-all.html">Index</a></li>
|
|
<li><a href="../../../../help-doc.html">Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="subNav">
|
|
<ul class="navList">
|
|
<li>Prev Package</li>
|
|
<li>Next Package</li>
|
|
</ul>
|
|
<ul class="navList">
|
|
<li><a href="../../../../index.html?org/apache/commons/csv/package-summary.html" target="_top">Frames</a></li>
|
|
<li><a href="package-summary.html" target="_top">No Frames</a></li>
|
|
</ul>
|
|
<ul class="navList" id="allclasses_navbar_bottom">
|
|
<li><a href="../../../../allclasses-noframe.html">All Classes</a></li>
|
|
</ul>
|
|
<div>
|
|
<script type="text/javascript"><!--
|
|
allClassesLink = document.getElementById("allclasses_navbar_bottom");
|
|
if(window==top) {
|
|
allClassesLink.style.display = "block";
|
|
}
|
|
else {
|
|
allClassesLink.style.display = "none";
|
|
}
|
|
//-->
|
|
</script>
|
|
</div>
|
|
<a name="skip.navbar.bottom">
|
|
<!-- -->
|
|
</a></div>
|
|
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
|
<p class="legalCopy"><small>Copyright © 2019 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
|
|
</body>
|
|
</html>
|