You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bu...@apache.org on 2014/12/01 16:19:58 UTC
svn commit: r931176 [3/3] - in /websites/production/camel/content:
book-dataformat-appendix.html book-in-one-page.html cache/main.pageCache
csv.html
Modified: websites/production/camel/content/csv.html
==============================================================================
--- websites/production/camel/content/csv.html (original)
+++ websites/production/camel/content/csv.html Mon Dec 1 15:19:57 2014
@@ -86,7 +86,12 @@
<tbody>
<tr>
<td valign="top" width="100%">
-<div class="wiki-content maincontent"><h2 id="CSV-CSV">CSV</h2><p>The CSV <a shape="rect" href="data-format.html">Data Format</a> uses <a shape="rect" class="external-link" href="http://commons.apache.org/proper/commons-csv/">Apache Commons CSV</a> to handle CSV payloads (Comma Separated Values) such as those exported/imported by Excel.</p><h3 id="CSV-Options">Options</h3><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>config</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>CSVConfig</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Can be used to set a custom <code>CSVConfig</code> object.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>strategy</p></td><td colsp
an="1" rowspan="1" class="confluenceTd"><p>CSVStrategy</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Can be used to set a custom <code>CSVStrategy</code>; the default is <code>CSVStrategy.DEFAULT_STRATEGY</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>autogenColumns</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>boolean</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Whether or not columns are auto-generated in the resulting CSV. The default value is <code>true</code>; subsequent messages use the previously created columns with new fields being added at the end of the line.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>delimiter</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>String</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong> The column delimiter to use; the default value is "<code>,</code>".</p></td></tr><tr><td colspan="1" rowspan="1"
class="confluenceTd"><p>skipFirstLine</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>boolean</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Whether or not to skip the first line of CSV input when unmarshalling (e.g. if the content has headers on the first line); the default value is <code>false</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">lazyLoad</td><td colspan="1" rowspan="1" class="confluenceTd">boolean</td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.12.2:</strong><span><span> Whether or not to </span></span><span style="line-height: 1.4285715;">Sequential access CSV input through an iterator which could avoid OOM exception when processing huge CSV file; </span><span>the default value is false </span></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">useMaps</td><td colspan="1" rowspan="1" class="confluenceTd">boolean</td><td colspan="1" rowspan="1" class="co
nfluenceTd"><strong>Camel 2.13:</strong> Whether to use List<Map> when unmarshalling instead of List<List>.</td></tr></tbody></table></div><h3 id="CSV-MarshallingaMaptoCSV">Marshalling a Map to CSV</h3><p>The component allows you to marshal a Java Map (or any other message type that can be <a shape="rect" href="type-converter.html">converted</a> in a Map) into a CSV payload.</p><p>An example: if you send a message with this map...</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<div class="wiki-content maincontent"><h2 id="CSV-CSV">CSV</h2><p>The CSV <a shape="rect" href="data-format.html">Data Format</a> uses <a shape="rect" class="external-link" href="http://commons.apache.org/proper/commons-csv/">Apache Commons CSV</a> to handle CSV payloads (Comma Separated Values) such as those exported/imported by Excel.</p><p>As of Camel 2.15.0, it now uses the <a shape="rect" class="external-link" href="http://commons.apache.org/proper/commons-csv/archives/1.1/index.html">Apache Commons CSV 1.1</a> which is based on a completely different set of options.</p><h3 id="CSV-AvailableoptionsuntilCamel2.15">Available options until Camel 2.15</h3><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"
><p>config</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>CSVConfig</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Can be used to set a custom <code>CSVConfig</code> object.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>strategy</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>CSVStrategy</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Can be used to set a custom <code>CSVStrategy</code>; the default is <code>CSVStrategy.DEFAULT_STRATEGY</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>autogenColumns</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>boolean</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Whether or not columns are auto-generated in the resulting CSV. The default value is <code>true</code>; subsequent messages use the previously created columns with new fields being added at the end of the line.</p></td></tr><tr><td colspan="1" rowspan="1" class="
confluenceTd"><p>delimiter</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>String</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.4:</strong> The column delimiter to use; the default value is "<code>,</code>".</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>skipFirstLine</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>boolean</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><strong>Camel 2.10:</strong> Whether or not to skip the first line of CSV input when unmarshalling (e.g. if the content has headers on the first line); the default value is <code>false</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">lazyLoad</td><td colspan="1" rowspan="1" class="confluenceTd">boolean</td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.12.2:</strong><span><span> Whether or not to </span></span><span style="line-height: 1.4285715;">Sequential access CSV input through
an iterator which could avoid OOM exception when processing huge CSV file; </span><span>the default value is false </span></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">useMaps</td><td colspan="1" rowspan="1" class="confluenceTd">boolean</td><td colspan="1" rowspan="1" class="confluenceTd"><strong>Camel 2.13:</strong> Whether to use List<Map> when unmarshalling instead of List<List>.</td></tr></tbody></table></div><h3 id="CSV-AvailableoptionsasofCamel2.15">Available options as of Camel 2.15</h3><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Option</th><th colspan="1" rowspan="1" class="confluenceTh">Type</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>format</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>CSVFormat</code></td><td colspan="1" rowspan="1" class="confluenceTd">The reference
format to use, it will be updated with the other format options, the default value is <code>CSVFormat.DEFAULT</code></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>formatName</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>String</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Used in order to initialize the reference format using the name of one of the default formats.</p><p>The possible values are: <code>"DEFAULT"</code>, <code>"RFC4180"</code>, <code>"EXCEL"</code>, <code>"TDF"</code>, <code>"MYSQL"</code></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>commentMarker</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>Character</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the comment marker of the reference format.</p><p>This option is <code>null</code> by default. When <code>null</code> it keeps the value of the reference format which is <code>null</code> for
<code>CSVFormat.DEFAULT</code>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>delimiter</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>Character</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the delimiter of the reference format.</p><p>This option is <code>null</code> by defaut. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </span><code>','</code><span> for </span><code>CSVFormat.DEFAULT</code><span>.</span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>escapeDisabled</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disables the escape character of the reference format.</p><p>This option is <code>false</code> by default.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>escape</code></td><td colspan="1" rowspan="1" class="confluenc
eTd"><code>Character</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the escape character of the reference format.</p><p>This option is <code>null</code> by default. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </span><code>null</code><span> for </span><code>CSVFormat.DEFAULT</code><span>.</span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>headerDisabled</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disables the header of the reference format.</p><p>This option is <code>false</code> by default.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>header</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>String[]</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the header of the reference format.</p><p>This option is <code>null</code> by
default. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </span><code>null</code><span> for </span><code>CSVFormat.DEFAULT</code><span>.</span></p><p>In the XML DSL, this option is configured using children <code><header></code> tags:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[<csv formatRef="excelFormat" delimiter="|" skipHeaderRecord="true">
+ <header>orderId</header>
+ <header>amount</header>
+</csv>]]></script>
+</div></div></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>allowMissingColumnNames</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>Boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the missing column names behavior of the reference format.</p><p>This option is <code>null</code> by default. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </span><code>false</code><span> for </span><code>CSVFormat.DEFAULT</code><span>.</span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>ignoreEmptyLines</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>Boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the empty line behavior of the reference format.</p><p><span>This option is </span><code>null</code><span> by default. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </sp
an><code>true</code><span> for </span><code>CSVFormat.DEFAULT</code><span>.</span></span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>ignoreSurroundingSpaces</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>Boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the surrounding spaces behavior of the reference format.</p><p><span>This option is </span><code>null</code><span> by default. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </span><code>false</code><span> for </span><code>CSVFormat.DEFAULT</code><span>.</span></span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>nullStringDisabled</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disables the null string representation of the reference format.</p><p>This option is <code>false</code> by default.</p>
</td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>nullString</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>String</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the null string representation of the reference format.</p><p><span>This option is </span><code>null</code><span> by default. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </span><code>null</code><span> for </span><code>CSVFormat.DEFAULT</code><span>.</span></span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>quoteDisabled</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disables the quote of the reference format.</p><p><span>This option is </span><code>false</code><span> by default.</span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>quote</code></td><td colspan="1" rowspan
="1" class="confluenceTd"><code>Character</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the quote symbol of the reference format.</p><p><span>This option is </span><code>null</code><span> by default. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </span><code>'"'</code><span> (double quote) for </span><code>CSVFormat.DEFAULT</code><span>.</span></span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>quoteMode</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>QuoteMode</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the quote mode of the reference format.</p><p><span>This option is </span><code>null</code><span> by default. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </span><code>null</code><span> for </span><code>CSVFormat.DEFAULT</code><span>.</span></span></p></td></tr><tr><td colspan="1" rowspa
n="1" class="confluenceTd"><code>recordSeparatorDisabled</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disables the record separator of the reference format.</p><p><span>This option is </span><code>false</code><span> by default.</span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>recordSeparator</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>String</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the record separator of the reference format.</p><p><span>This option is </span><code>null</code><span> by default. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </span><code>\r\n</code><span> (CRLF) for </span><code>CSVFormat.DEFAULT</code><span>.</span></span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>skipHeaderRecord</code></td><td colspan="1" rowspan="
1" class="confluenceTd"><code>Boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the header record behavior of the reference format.</p><p><span>This option is </span><code>null</code><span> by default. <span>When </span><code>null</code><span> it keeps the value of the reference format which is </span><code>false</code><span> for </span><code>CSVFormat.DEFAULT</code><span>.</span></span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>lazyLoad</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Whether the unmarshalling should produce an iterator that reads the lines on the fly or if all the lines must be read at one.</p><p>This option is <code>false</code> by default.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>useMaps</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>boolean</code></td><td
colspan="1" rowspan="1" class="confluenceTd"><p>Whether the unmarshalling should produce maps for the lines values instead of lists. It requires to have header (either defined or collected).</p><p>This options is <code>false</code> by default.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><code>recordConverter</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>CsvRecordConverter</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sets the record converter to use. If defines the <code>useMaps</code> options is disabled.</p><p><span>This option is </span><code>null</code><span> by default.</span></p></td></tr></tbody></table></div><h3 id="CSV-MarshallingaMaptoCSV">Marshalling a Map to CSV</h3><p>The component allows you to marshal a Java Map (or any other message type that can be <a shape="rect" href="type-converter.html">converted</a> in a Map) into a CSV payload.</p><p>An example: if you send a message with this map...</p><p>&#
160;</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
Map<String, Object> body = new HashMap<String, Object>();
body.put("foo", "abc");