CSV Converter from URL
This adapter reads a CSV text document (comma separated values) from any URL and outputs an XML document with UTF-8 character encoding and with element names that can refer to the column names.
Lines before the actual beginning of CSV data rows can be omitted as well as comment lines. Both CR (carriage return) and CRLF (carriage return line feed) will be interpreted as line breaks. Using the operation Iterate
, the adapter can iterate through the input document and output a result document for each iteration within the Technical Process.
Properties
Operation | Defines the operation executed by the function adapter Possible values:
|
Parameters
Adapter | Main adapter class (Do not change!) Possible values: de.softproject.integration.adapter.csv.CsvAdapter: Main class (default) |
start | First data row to be read (counting starts with 0; if the CSV file contains a header row, it will be omitted) Possible values:
|
count | Number of rows to be read (with operation Possible values:
|
id | Unique ID of the CSV Converter from URL component within the process context or the process instance (if you want to use multiple independently iterating CSV Converters from URL within the same process context) Possible values:
|
columnNamesInFirstRow | Interpret data fields in the CSV text file's first row as column headers and name the data field elements within the XML document correspondingly, if the values are valid XML names Possible values:
|
normalizeHeaderNames | Defines how headers should be normalized if they contain characters that are not XML-compliant, such as spaces or special characters. Possible values:
|
columnNamesAfterStart | Interpret values from the row defined within the parameter Possible values:
|
delimiter | Delimiter character between the fields of a record in the CSV text document Possible values:
|
rowName | Element name in the output XML document that wraps each data row Possible values: XML element name (without namespace) |
excel | Defines if the processed CSV text document has been exported from MS Excel (not a standard CSV format) and if the adapter must convert it Possible values:
|
useIndexedColumns | Add column numbers (starting with 0) to data element names, if no column headers are available Possible values:
|
commentStart | Prefix string to indicate comment lines; Matching lines will be omitted. Possible values:
|
inputEncoding | Character encoding of the input Possible values:
|
url | URL of the CSV text document to be read Possible values: Valid URL (e.g. |
encoding | Character encoding of the CSV text document Possible values:
|
Status values
-1 | An error occurred during the adapter's execution (for details see server log). |
0 | The adapter doesn't output data (anymore). When using the operation |
1 | The adapter outputs a result document. When using the operation |
Input
The adapter expects any structured CSV text file (that might be generated by MS Excel) with any delimiter character and with optional comment lines.
Output
This adapter outputs a UTF-8-encoded XML document with the following structure. For each processed line an element will be generated that has a name specified within the parameter rowName
:
<Csv>
<!-- If column names are copied -->
<Elementname rowNo="row number in the input">
<Columnname>value</Columnname>
<!--...-->
</Elementname>
<!-- If no column names are available -->
<Elementname rowNo="column number in the input">
<Column>value</Column>
<!--...-->
</Elementname>
<!-- If no column names are available and parameter 'useIndexedColumns' is enabled -->
<Elementname rowNo="row number in the output">
<Column_Columnnumber>value</Column_Columnnumber>
<!--...-->
</Elementname>
</Csv>
Example
A CSV text file with comments is processed that contains column headers only in the second line, for instance:
**** This line is just a comment and should not be processed. **** "METADATA","Value 1","Value 2","Value 3","Value 4","Value 5" "CustomerID","CompanyName","ContactName","ContactTitle","Address","PostalCode" "ALFKI","Alfreds Futterkiste","Maria Anders","Sales","Obere Str. 57","12209" **** This line is just a comment and should not be processed. **** "ANTON","Moreno Taquería","Antonio Moreno","Owner","Mataderos 2312","05023"
This requires to enable the adapter parameter columnNamesAfterStart
, and to set the parameter start
to 1
because both comment line and column header line won't be counted. When using the value Dataset
for the parameter rowName
, the following XML document will be generated:
<Csv>
<Dataset rowNo="2">
<CustomerID>ALFKI</CustomerID>
<CompanyName>Alfreds Futterkiste</CompanyName>
<ContactName>Maria Anders</ContactName>
<ContactTitle>Sales</ContactTitle>
<Address>Obere Str. 57</Address>
<PostalCode>12209</PostalCode>
</Dataset>
<Dataset rowNo="3">
<CustomerID>ANTON</CustomerID>
<CompanyName>Moreno Taquería</CompanyName>
<ContactName>Antonio Moreno</ContactName>
<ContactTitle>Owner</ContactTitle>
<Address>Mataderos 2312</Address>
<PostalCode>05023</PostalCode>
</Dataset>
</Csv>