The Parse CSV transformer lets you parse a csv text from a received text value or a file. If your data comes in binary form (typically from a file), you have to use the
toString() function to convert the binary data to String:
The Create CSV (advanced) aggregator lets you create a csv text from received text values. It employs a Data structure that defines the CSV columns in the resulting CSV file. Once defined, the columns appear as fields in the CSV module setup, available for mapping.
Let us assume you would like to export your Google contacts to a CSV file with two columns "Full Name" and "Email". The output bundle from the Google Contacts > Get contacts from a group module has the following structure (see on the right). The email addresses are stored inside the
Emails item, which is an array of collections, each collection containing two items:
If you employ the simple Create CSV module, you are offered a list of checkboxes corresponding to a bundle's top-level items. If you attempt to tick
Full name and
Emails items, the Create CSV module will produce the following output, which is probably not what you wished for:
"emails","fullName" "[object Object]","Shon Winer" "[object Object]","Lizeth Fulmore" "[object Object]","Hilario Gullatt" "[object Object]","Abby Eisenbarth"
Since the item
Full Name is of simple type Text, it is exported just fine. But the item
Emails, which is of a complex type Array of Collections, is exported as
[object Object], which is how Collections and Arrays are transformed to text by default.
To export content of the
Emails array instead, it is necessary to employ the Create CSV (advanced) module. The module will enable you to define individual columns of your CSV file and map items to them, including the nested ones.
Emailsarray and map its item
Emails: Emailmapped to column "Email" is of simple type Text, it will be exported correctly now:
"Full Name","Email" "Shon Winer","Shon@Winer.com" "Lizeth Fulmore","Lizeth@Fulmore.com" "Hilario Gullatt","Hilario@Gullatt.com" "Abby Eisenbarth","Abby@Eisenbarth.com"