It is very common for applications that work with tabular data to be able to export and import that data in the ‘CSV’ (Comma Separated Values) format. The CSV Parser node makes it really simple to process CSV data from one of the apps that you interact with; for example, Box and Dropbox. It does this by parsing the raw CSV data into App Connect flow context information that can then be used by any subsequent node in the App Connect flow.
The node is configured by supplying a small sample – a line or two – of the CSV data you want to parse. This allows the node to understand the structure of the data you want to process, and it means that all subsequent nodes in the flow can make use of that structure.
Using the CSV Parser node
You can use the CSV Parser node when you know that one of the previous nodes in your flow (or the flow API input) contains a string that contains CSV data. The next few sections go through the steps in using the CSV Parser node.
1. Find it
When you want to add a CSV Parser node to your flow, you can find it in the ‘Toolbox’ section.
2. Configure it
The CSV Parser node acts on a single string input – it expects this string to contain the CSV data when invoked at runtime.
CSV Parser options and data schema
When configuring the node, you provide a small sample of the CSV data you want to parse, which the node uses to work out the structure of the data you’re using; for example:
First1,Last1,”1 Street, Town1″,City1,AB1 1CD,firstname.lastname@example.org
First2,Last2,”2 Street, Town2″,City2,AB2 2CD,email@example.com
- Paste your sample CSV data into the ‘example CSV’ box.
- If your CSV starts with a ‘header’ line that names the fields (as in the example CSV data above), then select the checkbox ‘First row of the CSV data is a header’.
- Click ‘Generate Schema’
This creates the JSON schema that describes the structure of your CSV data.
If you used the ‘First row of the CSV data is a header’ option, then each field is named according to the ‘header’ data for the relevant column.
If not, then the fields are just numbered;
This structure is used throughout the rest of the flow. You can leave this completely untouched.
3. Use the output from the CSV Parser in subsequent nodes
The output from the CSV Parser node is an array in which each element has the structure generated from your sample. The following screenshot shows the structure being used as part of the ‘For each’ node. Notice that the field names are the same as the first line of the CSV sample:
This article has given a brief overview of the usage of the CSV Parser node in IBM App Connect. Watch this site for further updates and example on App Connect and the CSV Parser node.