# Handling CSVs
A Comma-separated values (CSV) file is a text file that stores tabular data. It stores the data in plain text and is human-readable.
We will be using the following sample CSV content:
Manufacturer, Model, Category, Item Name, Item Code, Description, Unit Cost, Unit Price, Taxable, Tax, Custom Field 1, Custom Field 2, Custom Field 3 Sierra Gardening, MS-321, Gardening supplies, Pine wood potting bench, MS-321, Oakwood potting bench, 74.50, 119.99, Yes, 0.0875, Pine, White, 30 inches Sierra Gardening, MS-322, Gardening supplies, Cherry wood potting bench, MS-322, Oakwood potting bench, 74.50, 119.99, Yes, 0.0875, Cherry, Natural, 30 inches Sierra Gardening, MS-323, Gardening supplies, Cedar wood potting bench, MS-323, Oakwood potting bench, 74.50, 119.99, Yes, 0.0875, Cedar, Black, 30 inches
# CSV by Workato
Most web applications return CSV files without additional processing. You can use CSV by Workato to read the text content of the CSV file. This will allow you to move individual rows and transform the data as required by your use-case.
In this example, a new CSV file is picked up in Dropbox. Run the Parse CSV action to obtain a list of lines/rows.
Parse CSV. See the sample recipe here (opens new window).
# Input field
|CSV contents||Select a CSV |
|Column separator||Select the character that separates columns in the CSV file.|
|CSV contents contain header line||Indicate if there is a header line.|
|Header line||Specify the header line of your CSV file.|
|Keep track of columns by||Configure this if your CSV content does not have a fixed column order.|
|Quote Character||The character used to quote CSV cell values. Select |
# Output field
This action will generate an array of lines, with each line containing the schema as defined in your header line. As this is an array object, you would have to use a repeat action to iterate through the rows.
In our sample recipe, we iterate through each line of the array object and create a task in Wrike.
Mapping of datapills from the Repeat step datatree to the action
For more information on working with lists, see here.
# Parsing CSV files via external parser
Certain connectors have triggers/actions that can parse CSV content. The Box connector has this capability. You can simply listen to new CSV files and parse them via the same trigger.
CSV file parsing with a Box trigger. See the sample recipe here (opens new window).
# Input field
Similarly, input the header line for the CSV in the Field names. This is necessary to generate datapills in the output.
Defining the expected columns in the CSV files that the recipe will pick up. Example recipe (opens new window).
This trigger picks out all new CSV files regardless if they share the same schema or header lines. This may lead to job errors or bad data being moved into your app. If you have shared folders or sub-folders, ensure that only relevant CSV files are stored there or add a trigger filter to specify which files to pick up.
# Output field
The output from the Box CSV parser is the same as the output from CSV by Workato. The columns in the CSV content (as defined in the trigger) will show up as usable variables which can be used to map into subsequent recipe steps.
Similarly, run a repeat action to iterate through the list of CSV rows.
Using the variables defined in the Box trigger
Last updated: 3/29/2023, 2:00:59 PM