CSV to XML
You need to convert one or more CSV files to a XML format.
Json
Example
json
{
"name": "file-conversion-csv-to-xml",
"taskReferenceName": "csv_to_xml",
"description": "The business description of the task",
"type": "SUB_WORKFLOW",
"optional": false,
"inputParameters": {
"mode": "FILE",
"file": "${previous_TaskReferenceName.output.file}",
"columnSeparator": ";",
"textDelimiter": "\"",
"escapeCharacter": "\""
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
Definition
Property | Type | Required | Description |
---|---|---|---|
The name (or type) of the task | |||
The unique name of the task in your job. It is used to reference this task in the workflow. | |||
The functional description of this task in your job. | |||
The type of the task. It must be SUB_WORKFLOW . | |||
true : the job continues if there is an error on this task. false : the job fails. | |||
Input parameters of the task. See below |
Inputs
Property | Description |
---|---|
mode | Enum FILE |
file | A valid input. It can reference the output of a previous task, example: ${previous_taskReferenceName.output.file} , or a static file, example: file://assets/file.csv , or a user input, example: ${workflow.input.input_key} . |
files | A valid input. It can reference the output of a previous task, example: ${previous_taskReferenceName.output.files} , or a user input, example: ${workflow.input.input_key} . |
columnSeparator | The column separator. Usually ; or , or `` |
textDelimiter | How text are encapsulated. Usually " or ' |
escapeCharacter | If the text contains the text qualifier character, then it must be escaped. The escape character is usually the same than the text textDelimiter. For example: must be "Produit 1";"Télé 51"" ou plus" |
allowEmpty | optional true | false . true : empty values are exported, false : empty values are not exported. Default: false . |
Outputs
Property | Type | Description |
---|---|---|
file | An XML file as described below. | |
allFilesTransformed | YES | NO . YES : all files have been transformed successfully. NO : at least one file has not been transformed. |
Output file
Example
xml
<Csv-To-Xml>
<File>
<File-Name>products.csv</File-Name>
<Rows>
<R i="1">
<C j="1">EAN</C>
<C j="2">1234567890123</C>
<C j="3">1234567890124</C>
</R>
</Rows>
</File>
</Csv-To-Xml>
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
Definition
XPath | Description | Occurs |
---|---|---|
Csv-To-Xml | Root of the document. | 1 |
./File | For each input file. | 1..* |
./File/File-Name | Original file name. | 1 |
./File/Rows | Rows. | 1 |
./File/Rows/R | R = Row, one by row. | 0..* |
./File/Rows/R/@i | i = line index, start index is 1. | 1 |
./File/Rows/C | C = Column. | 0..* |
./File/Rows/C/@j | j = column index, start index is 1. | 1 |
Limits and additional notes
FAQ
How to manage multiple CSV files?
Use mode = FILES and the input files. They will be automatically merged into one single XML file.
Why you must have a text delimiter?
If you don't have a text delimiter you cannot have a carriage return in your CSV file because the cariage return is used as line separator. From experience, allowing no text delimiter will lead to big data integrity issues after a while.