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 17:21:27 UTC
svn commit: r931181 [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 16:21:27 2014
@@ -86,47 +86,44 @@
<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><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">
+<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>commentMarkerDisabled</code></td><td colspan="1" rowspan="1" class="confluenceTd"><code>boolean</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Disables the comment marker 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>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="confluenceTd"><code>Character</code></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Overrides the escape character of th
e 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>nul
l</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 >
<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>();
+</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><div class="table-wrap"><table class="confluenceTable"><tbody>
<tr><td colspan="1" rowspan="1" class="confluenceTd">Considering the following body</td><td colspan="1" rowspan="1" class="confluenceTd"><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 LinkedHashMap<>();
body.put("foo", "abc");
-body.put("bar", 123);
-]]></script>
-</div></div><p>... through this route ...</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[
-from("direct:start").
- marshal().csv().
- to("mock:result");
-]]></script>
-</div></div><p>... you will end up with a String containing this CSV message</p><div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
-<pre>abc,123</pre>
-</div></div><p>Sending the Map below through this route will result in a CSV message that looks like <code>foo,bar</code></p><h3 id="CSV-UnmarshallingaCSVmessageintoaJavaList">Unmarshalling a CSV message into a Java List</h3><p>Unmarshalling will transform a CSV messsage into a Java List with CSV file lines (containing another List with all the field values).</p><p>An example: we have a CSV file with names of persons, their IQ and their current activity.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
-<script class="theme: Default; brush: text; gutter: false" type="syntaxhighlighter"><![CDATA[
-Jack Dalton, 115, mad at Averell
+body.put("bar", 123);]]></script>
+</div></div></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">and this Java route definition</td><td colspan="1" rowspan="1" class="confluenceTd"><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[from("direct:start")
+ .marshal().csv()
+ .to("mock:result");]]></script>
+</div></div></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">or this XML route definition</td><td colspan="1" rowspan="1" class="confluenceTd"><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[<route>
+ <from uri="direct:start" />
+ <marshal>
+ <csv />
+ </marshal>
+ <to uri="mock:result" />
+</route>]]></script>
+</div></div></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd">then it will produce</td><td colspan="1" rowspan="1" class="confluenceTd"><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: text; gutter: false" type="syntaxhighlighter"><![CDATA[abc,123]]></script>
+</div></div></td></tr></tbody></table></div><h3 id="CSV-UnmarshallingaCSVmessageintoaJavaList"><span style="font-size: 16.0px;line-height: 1.5625;">Unmarshalling a CSV message into a Java List</span></h3><p>Unmarshalling will transform a CSV messsage into a Java List with CSV file lines (containing another List with all the field values).</p><p><span style="line-height: 1.4285715;">An example: we have a CSV file with names of persons, their IQ and their current activity.</span></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: text; gutter: false" type="syntaxhighlighter"><![CDATA[Jack Dalton, 115, mad at Averell
Joe Dalton, 105, calming Joe
William Dalton, 105, keeping Joe from killing Averell
Averell Dalton, 80, playing with Rantanplan
-Lucky Luke, 120, capturing the Daltons
-]]></script>
+Lucky Luke, 120, capturing the Daltons]]></script>
</div></div><p>We can now use the CSV component to unmarshal this file:</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[
-from("file:src/test/resources/?fileName=daltons.csv&noop=true").
- unmarshal().csv().
- to("mock:daltons");
-]]></script>
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[from("file:src/test/resources/?fileName=daltons.csv&noop=true")
+ .unmarshal().csv()
+ .to("mock:daltons");]]></script>
</div></div><p>The resulting message will contain a <code>List<List<String>></code> like...</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[
-List<List<String>> data = (List<List<String>>) exchange.getIn().getBody();
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[List<List<String>> data = (List<List<String>>) exchange.getIn().getBody();
for (List<String> line : data) {
- LOG.debug(String.format("%s has an IQ of %s and is currently %s",
- line.get(0), line.get(1), line.get(2)));
-}
-]]></script>
+ LOG.debug(String.format("%s has an IQ of %s and is currently %s", line.get(0), line.get(1), line.get(2)));
+}]]></script>
</div></div><h3 id="CSV-MarshallingaList<Map>toCSV">Marshalling a List<Map> to CSV</h3><p><strong>Available as of Camel 2.1</strong></p><p>If you have multiple rows of data you want to be marshalled into CSV format you can now store the message payload as a <code>List<Map<String, Object>></code> object where the list contains a Map for each row.</p><h3 id="CSV-FilePollerofCSV,thenunmarshaling">File Poller of CSV, then unmarshaling</h3><p>Given a bean which can handle the incoming data...</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>MyCsvHandler.java</b></div><div class="codeContent panelContent pdl">
<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[// Some comments here
public void doHandleCsvData(List<List<String>> csvData)
@@ -142,36 +139,33 @@ public void doHandleCsvData(List<List
<to uri="bean:myCsvHandler?method=doHandleCsvData" />
</route>
]]></script>
-</div></div><h3 id="CSV-Marshalingwithapipeasdelimiter">Marshaling with a pipe as delimiter</h3><p>Using the Spring/XML DSL:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="CSV-Marshalingwithapipeasdelimiter">Marshaling with a pipe as delimiter</h3><p> </p><p> </p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><td colspan="1" rowspan="1" class="confluenceTd">Considering the following body</td><td colspan="1" rowspan="1" class="confluenceTd"><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 LinkedHashMap<>();
+body.put("foo", "abc");
+body.put("bar", 123);]]></script>
+</div></div></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><span>and this Java route definition</span></td><td colspan="1" rowspan="1" class="confluenceTd"><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[// Camel version < 2.15
+CsvDataFormat oldCSV = new CsvDataFormat();
+oldCSV.setDelimiter("|");
+from("direct:start")
+ .marshal(oldCSV)
+ .to("mock:result")
+Â
+// Camel version >= 2.15
+from("direct:start")
+ .marshal(new CsvDataFormat().setDelimiter('|'))
+ .to("mock:result")]]></script>
+</div></div></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><span>or this XML route definition</span></td><td colspan="1" rowspan="1" class="confluenceTd"><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[<route>
<from uri="direct:start" />
<marshal>
<csv delimiter="|" />
</marshal>
- <to uri="bean:myCsvHandler?method=doHandleCsv" />
-</route>
-]]></script>
-</div></div><p>Or the Java DSL:</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[CsvDataFormat csv = new CsvDataFormat();
-CSVConfig config = new CSVConfig();
-config.setDelimiter('|');
-csv.setConfig(config);
-
-from("direct:start")
- .marshal(csv)
- .convertBodyTo(String.class)
-.to("bean:myCsvHandler?method=doHandleCsv");
-]]></script>
-</div></div><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[CsvDataFormat csv = new CsvDataFormat();
-csv.setDelimiter("|");
-
-from("direct:start")
- .marshal(csv)
- .convertBodyTo(String.class)
-.to("bean:myCsvHandler?method=doHandleCsv");
-]]></script>
-</div></div><h3 id="CSV-UsingautogenColumns,configRefandstrategyRefattributesinsideXMLDSL">Using autogenColumns, configRef and strategyRef attributes inside XML DSL</h3><p><strong>Available as of Camel 2.9.2 / 2.10</strong></p><p>You can customize the CSV <a shape="rect" href="data-format.html">Data Format</a> to make use of your own <code>CSVConfig</code> and/or <code>CSVStrategy</code>. Also note that the default value of the <code>autogenColumns</code> option is true. The following example should illustrate this customization.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+ <to uri="mock:result" />
+</route>]]></script>
+</div></div></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><span>then it will produce</span></td><td colspan="1" rowspan="1" class="confluenceTd"><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<script class="theme: Default; brush: text; gutter: false" type="syntaxhighlighter"><![CDATA[abc|123]]></script>
+</div></div></td></tr></tbody></table></div><h3 id="CSV-UsingautogenColumns,configRefandstrategyRefattributesinsideXMLDSL">Using autogenColumns, configRef and strategyRef attributes inside XML DSL</h3><p><strong>Available as of Camel 2.9.2 / 2.10 and deleted for Camel 2.15</strong></p><p>You can customize the CSV <a shape="rect" href="data-format.html">Data Format</a> to make use of your own <code>CSVConfig</code> and/or <code>CSVStrategy</code>. Also note that the default value of the <code>autogenColumns</code> option is true. The following example should illustrate this customization.</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[<route>
<from uri="direct:start" />
<marshal>
@@ -199,7 +193,7 @@ from("direct:start")
<property name="staticField" value="org.apache.commons.csv.CSVStrategy.EXCEL_STRATEGY" />
</bean>
]]></script>
-</div></div><h3 id="CSV-UsingskipFirstLineoptionwhileunmarshaling">Using skipFirstLine option while unmarshaling</h3><p><strong>Available as of Camel 2.10</strong></p><p>You can instruct the CSV <a shape="rect" href="data-format.html">Data Format</a> to skip the first line which contains the CSV headers. Using the Spring/XML DSL:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><h3 id="CSV-UsingskipFirstLineoptionwhileunmarshaling">Using skipFirstLine option while unmarshaling</h3><p><strong>Available as of Camel 2.10 and deleted for Camel 2.15</strong></p><p>You can instruct the CSV <a shape="rect" href="data-format.html">Data Format</a> to skip the first line which contains the CSV headers. Using the Spring/XML DSL:</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[<route>
<from uri="direct:start" />
<unmarshal>