top of page
Writer's picturefutureprooftechskills

5 Dataweave CSV Use Cases for your next integration

Updated: Apr 5, 2023

There are times where some integrations require data to be read or written as comma separated values or csv. To do so, Dataweave offers a csv format. Read along to review some CSV fundamentals in Dataweave.


Quick Navigation


This tutorial will use two previously read CSV files. One is stored as payload, while the other is stored in a variable called newFile.


payload:


FirstName, LastName, Age
Whitney, George, 20
Cheryl, Gold, 25
Jeanette, Godwin, 30

Variable - newFile:


FirstName, LastName, Age
Monica, Good, 35
Gabby, Gates, 25
Stephanie, Gaines, 40

Use Case 1: Retrieve all values in a column

Example: Retrieve a list of FirstNames.




Use Case 2: Access a row (record) of information

Example: Access the first row

Notice: Each row is an object of key-value pairs



Use Case 3: Concatenate two csv formatted files

Example: Two files stored in memory are concatenated. One is stored as a payload and one is stored as a variable called newFile.

Notice: This example was done in Dataweave Playground. Inside studio you would access variables using vars.<variable_name>. See below code block.
%dw 2.0 
output application/csv
---
payload ++ vars.newFile

Use Case 4: Convert as String

Example: You want to log the payload as a string.



Use Case 5: Enable streaming from DataWeave

Enable streaming while writing. You can do this by setting the CSV "deferred" writer property to true. Interested in learning how to do this? Check out my mini-course here.

1,886 views0 comments

Recent Posts

See All
bottom of page