csv

Parse a csv file.

This guide explains how to configure the csv instruction. To learn about another instruction, go back to the Available custom script instructions overview.

Introduction

Use the csv instruction to parse a csv file. If you want to parse a text file, use the text enrichment. When configuring the enrichment, choose if the parsed fields are to be returned as quotes.

Creating a custom script enrichment using the csv instruction

To create and configure a custom script using the csv instruction, follow these steps:

  1. Create a custom script enrichment.

  2. In the Instructions step, select the csv instruction.

  3. To configure the custom script instruction, fill in the following fields. Required fields are marked with an asterisk (*).

Encoding

Select the format in which the csv file has been encoded. Select one of the following:

  • utf-8

  • utf-8-sig

  • utf-16

  • utf-16le

  • iso-8859-1

  • iso-8859-9

  • iso-8859-15

  • cp437

Delimiter

Enter the character used to separate the fields in the csv file. The default delimiter is the comma (,).

Quotechar

Enter the character used to identify quotes. All fields in the csv file to be quoted are contained inside the selected quote character. For example, the field of clicks would be quoted as "clicks" if the quote character is the quotation mark ("). The default quote character is the quotation mark (").

Quoting

Select how the instruction returns the fields as quotes. Chose one of the following options:

  • All - Select this option to return all parsed fields as quotes.

  • Minimal - Select this option to parse the fields into quotes if the selected delimiters or quote characters surround the fields.

  • None - Select this option to parse the fields without the quote characters.

  • Nonnumeric - Select this option to parse all text data as quotes and convert all numeric fields to float data type.

Subtable

Enter the name for a subtable that you want to use within this custom script.

A subtable is a temporary table that only exists for this custom script. You can apply additional instructions within the same custom script to the subtable. However, the subtable cannot be used in any other custom scripts.

If a subtable does not exist for the current custom script, the enrichment is applied to the data extract, and the enriched data is output into the subtable. If the subtable already exists for the custom script, the subtable is used as the input for the enrichment and optionally as the output.