Skip to content

CSV Actions

The CSV Actions provide tools for creating, reading, updating, parsing, and converting CSV data. These actions are useful when working with structured tabular data from spreadsheets, reports, exports, databases, or other systems that exchange information in CSV format. CSV data can be dynamically built from variables, modified, sorted, or broken into individual values, allowing your Automations to generate files, process records line-by-line, or transform CSV into HTML for reporting and email output. Together, these actions make it easy to incorporate CSV workflows without requiring external tools or manual intervention.

Update CSV

Create or update a comma separated values (CSV) file or CSV data.

You can either update a CSV File or a variable containing CSV data.

Enter or select the CSV File Name to update. This is the full path and filename of the CSV file you want to update. This is optional. If no file name is specified then the created CSV data will be assigned to the variable selected from the Assign To list.

ThinkAutomation will create the path and file if it does not already exist. Column names will be written to the header line of the new file (unless the Don't Add Field Header Line When Creating option is enabled).

Select the file Format of the CSV file. This can be ASCII, Unicode or UTF-8 (default).

Select the Column Delimiter. This is normally a comma, but can be any character. You can select select a | (pipe) character, semi-colon or TAB from the drop down.

Select the Line Terminator. This can be CRLF (Carriage Return/Line Feed), LF (Line Feed Only). CRLF is the default.

Select Don't Add Field Header Line When Creating if you want the CSV data to contain data lines only. By default, when the CSV file is first created the first line will contain the column headers.

Use Custom Columns List

By default ThinkAutomation will create CSV data with a column for each Extract Field action in your Automation. Enable Use Custom Columns List to specify a list of %variables% to include in each column. You can also specify the column header names.

Optionally select a variable from the Assign CSV Data To list to receive the updated CSV data.


Read CSV

Read a CSV file or %variable% containing CSV data and assign the CSV data to a variable.

This action allows you to read a CSV file (or a %variable% containing CSV data). You can optionally delete columns from then returned CSV data and sort by a column. The column delimiter character and line endings will be automatically detected when the CSV is loaded. However the returned CSV data will always use a comma as the delimiter. Any date & datetime values will be automatically normalized to date format yyyy-MM-dd HH🇲🇲ss in the returned CSV data.

Specify the CSV File Name or Variable. This field can contain a file path (or %variable% containing a file path) or a %variable% containing CSV data.

Enable the Has Header Row if the CSV data contains column headers on the first row.

Deleting Columns

You can optionally delete columns from the returned CSV data. Specify a comma separated list of column header names, or column numbers (starting at 1). The source CSV file/data is not changed - this setting only affects the CSV data that is returned.

Deleting Last Rows

You can optionally delete the last x rows from the returned CSV data. Specify the number of rows to remove in the Delete Last Rows entry. For example, if this is set to 2 then the last 2 rows will be removed (before any sorting). This can be useful if you have extracted the CSV data from an Excel file (using the Lookup From Excel action) and the CSV data contains additional summary rows at the end. The source CSV file/data is not changed.

Sorting

You can sort the returned CSV data by a column. Specify the column header name or column number (starting at 1) in the Return Sorted By Column entry. You can select to sort Ascending or Descending. If you use column number here then the number relates to the new CSV columns after any columns have been deleted.

Return Top Rows

You can choose to only return the first x rows (after any sorting). Leave this entry at zero for all rows.

Return Header Row

Disable this setting if you do not want the column header row included in the returned CSV data.

Select the %variable% to receive the CSV data from the Assign CSV Data To list.


Parse CSV Line

Extract values from comma separated text.

Select the CSV value to parse from the Parse CSV Line In list.

In the Column Assignments grid, for each column you want to extract enter the Column Number and select the Assign Value To variable to receive the column value.

Column numbers are 1 based.

This action will correctly handle quoted values.

This action is useful when used with the For..Each loop, looping on Line. This enables you to read a CSV file (or Attachment) and loop on each line. Inside the loop use this action to parse each CSV line.


Convert CSV To HTML

Converts any CSV text to a HTML table.

This action is useful when you read CSV data from a database lookup and you need to easily convert the content to readable HTML. The HTML can then be included on outgoing emails or used as a return value for webform Message Sources.

In the CSV editor, enter or paste the CSV text, or use a %variable% replacement for CSV data created from an earlier action.

The Preview window will show a preview of the HTML created. The CSV will be converted to a HTML table.

You can optionally add a Title which will appear above the table.

If the Return Full Page option is enabled then the returned HTML will include html, body, head tags. Otherwise only the table html will be returned. This is useful if you are embedding the table into an existing HTML document.

If the Use Default Styles option is enabled then the table will have a default style sheet applied.

You can also optionally add any custom CSS (eg: body {background-color: lightblue;}).

Enable the Add Bootstrap Classes to add Bootstrap class names to the table. You can then enable other Bootstrap classes: Bordered, Hoverable, Responsive, Small & Striped Rows. You can also select the Bootstrap Color.

Select the ThinkAutomation variable to receive the HTML from the Assign Html To list.

Example:

The following CSV:

year,color,country,food
2001,red,France,cheese
2005,blue,"United States",hamburger
2008,green,Italy,pasta

Would be converted to:

<table>
  <col style="width:15.38%" />
  <col style="width:17.95%" />
  <col style="width:38.46%" />
  <col style="width:28.21%" />
  <thead>
    <tr>
      <th style="text-align: right;">Year</th>
      <th>Color</th>
      <th>Country</th>
      <th>Food</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td style="text-align: right;">2001</td>
      <td>red</td>
      <td>France</td>
      <td>cheese</td>
    </tr>
    <tr>
      <td style="text-align: right;">2005</td>
      <td>blue</td>
      <td>United States</td>
      <td>hamburger</td>
    </tr>
    <tr>
      <td style="text-align: right;">2008</td>
      <td>green</td>
      <td>Italy</td>
      <td>pasta</td>
    </tr>
  </tbody>
</table>