CSV
CSV Map Configuration
config.xml
<map>
<id>Map04</id>
<enabled>true</enabled>
<description>CSV to XML</description>
<enableEmailNotifications>true</enableEmailNotifications>
<connectors>
<input>
<id>in1</id>
<description>Read CSV</description>
<type>CSV</type>
<url>
<path>./interface/input/Map04 CSV to XML</path>
<mask/>
<prefix/>
<pollingInterval>1000</pollingInterval>
</url>
<csv>
<optionDelimeter>^</optionDelimeter>
<csvOptions>separator=,^quote=none</csvOptions>
</csv>
</input>
<output>
<id>out1</id>
<enabled>true</enabled>
<description>Write XML</description>
<type>XML</type>
<url>
<path>./interface/output/Map04 CSV to XML</path>
<prefix/>
<fileExtension/>
<use83GUID>false</use83GUID>
</url>
<xsl>
<XSLT>Map04_CSV_to_XML.xsl</XSLT>
<XSLTPath/>
</xsl>
</output>
</connectors>
</map>
The CSV input connector uses the OpenCSV library and requires very little configuration. The are a pair of settings which you should review
<optionDelimeter>^</optionDelimeter>
and
<csvOptions>separator=,^quote="</csvOptions>
In the <csvOptions>separator=,^quote="</csvOptions> element you will see that 2 values are set, separator and quote. These 2 settings are separated by a delimiter which happens to be **^** in this example. However if by some unfortunate coincedence your CSV file uses that character as a value separater then you might need to use a different delimited in the configuration - which is where the `<optionDelimeter>^</optionDelimeter>` can be used.
NOTE that if you don't want a quote character this should be represented as shown below with _none_ used as the value.
<csvOptions>separator=,^quote=none</csvOptions>
CSV Output Configuration
<map>
<id>Map12</id>
<enabled>true</enabled>
<description>XML to CSV</description>
<enableEmailNotifications>true</enableEmailNotifications>
<connectors>
<input>
<id>in1</id>
<description>Read XML File</description>
<type>XML</type>
<url>
<path>./interface/input/Map12 XML to CSV</path>
<mask/>
<prefix/>
<pollingInterval>1000</pollingInterval>
</url>
<xsl>
<XSLTPath/>
<XSLT>Map12_XML_to_CSV.xsl</XSLT>
</xsl>
</input>
<output>
<id>out1</id>
<enabled>true</enabled>
<description>Write CSV</description>
<type>CSV</type>
<url>
<path>./interface/output/Map12 XML to CSV</path>
<prefix>X</prefix>
<fileExtension>csv</fileExtension>
<use83GUID>true</use83GUID>
</url>
<csv>
<optionDelimeter>^</optionDelimeter>
<csvOptions>separator=,^quote=none</csvOptions>
</csv>
</output>
</connectors>
</map>
Element | Value | Description |
---|---|---|
path | Path | Specifies where output files are saved. |
type | CSV | Specify the output file format |
optionDelimeter | char | See earlier description. |
csvOptions | var=val | See earlier description. |
outputFileExtension | Blank or ext | File extension to use for output file. |
prefix | String | Option to force all output files to begin with a specific string prefix |
use83GUID | Y or N | For backwards compatibility with legacy apps which don't support long filenames. Generates a filename in 8.3 format |
XSLT | filename | Not used |
CSV Example Input
GEN Comma Separated Variables 1.csv
01050213060215701000123780990210133980001,150213061500000017,15,15000,0210133,5021306021570,1008369,LS 2D BLU,1000,00123780 01050213060215701000123780990210133980002,150213061500000017,15,15000,0210133,5021306021570,1008369,LS 2D BLU,1000,00123780 01050213060215701000123780990210133980003,150213061500000017,15,15000,0210133,5021306021570,1008369,LS 2D BLU,1000,00123780 01050213060215701000123780990210133980004,150213061500000017,15,15000,0210133,5021306021570,1008369,LS 2D BLU,1000,00123780 01050213060215701000123780990210133980005,150213061500000017,15,15000,0210133,5021306021570,1008369,LS 2D BLU,1000,00123780
CSV to XML Intermediate Format
<?xml version="1.0" encoding="UTF-8"?>
<data cols="10" filename="GEN Comma Separated Variables 1.csv" rows="5" type="CSV">
<row id="1">
<col id="1">01050213060215701000123780990210133980001</col>
<col id="2">150213061500000017</col>
<col id="3">15</col>
<col id="4">15000</col>
<col id="5">0210133</col>
<col id="6">5021306021570</col>
<col id="7">1008369</col>
<col id="8">LS 2D BLU</col>
<col id="9">1000</col>
<col id="10">00123780</col>
</row>
<row id="2">
<col id="1">01050213060215701000123780990210133980002</col>
<col id="2">150213061500000017</col>
<col id="3">15</col>
<col id="4">15000</col>
<col id="5">0210133</col>
<col id="6">5021306021570</col>
<col id="7">1008369</col>
<col id="8">LS 2D BLU</col>
<col id="9">1000</col>
<col id="10">00123780</col>
</row>
<row id="3">
<col id="1">01050213060215701000123780990210133980003</col>
<col id="2">150213061500000017</col>
<col id="3">15</col>
<col id="4">15000</col>
<col id="5">0210133</col>
<col id="6">5021306021570</col>
<col id="7">1008369</col>
<col id="8">LS 2D BLU</col>
<col id="9">1000</col>
<col id="10">00123780</col>
</row>
<row id="4">
<col id="1">01050213060215701000123780990210133980004</col>
<col id="2">150213061500000017</col>
<col id="3">15</col>
<col id="4">15000</col>
<col id="5">0210133</col>
<col id="6">5021306021570</col>
<col id="7">1008369</col>
<col id="8">LS 2D BLU</col>
<col id="9">1000</col>
<col id="10">00123780</col>
</row>
<row id="5">
<col id="1">01050213060215701000123780990210133980005</col>
<col id="2">150213061500000017</col>
<col id="3">15</col>
<col id="4">15000</col>
<col id="5">0210133</col>
<col id="6">5021306021570</col>
<col id="7">1008369</col>
<col id="8">LS 2D BLU</col>
<col id="9">1000</col>
<col id="10">00123780</col>
</row>
</data>
XML Example Output from XSLT
<?xml version="1.0" encoding="UTF-8"?>
<test>
<barcode>01050213060215701000123780990210133980001</barcode>
<barcode>01050213060215701000123780990210133980002</barcode>
<barcode>01050213060215701000123780990210133980003</barcode>
<barcode>01050213060215701000123780990210133980004</barcode>
<barcode>01050213060215701000123780990210133980005</barcode>
</test>