Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Snap type:

Parse


Description:

This Snap reads CSV binary data from its input view, parses and writes it as CSV document data to its output view.


Prerequisites:

[None]


Support and limitations:Works in Ultra Task Pipelines.
Account: 

Accounts are not used with this Snap.


Views:


Input

This Snap has at most two binary input views, where it gets the CSV binary data to be parsed.

If there are two input views, it gets the CSV binary data to be parsed from the first input view and the CSV metadata from the second input view. The metadata should be a CSV format with two lines of CSV data: the first line is the CSV header, the second, data types. Supported data types are 'string', 'integer', 'float' and 'boolean'. If 'string' is a default data type, empty data type fields are considered to be 'string' type. An example of CSV metadata is:

Last name,First name,age,commute_km,isDriving

string, ,integer,float,boolean


Output

This Snap has exactly one document output view, where it provides the CSV document data stream.


Error

This Snap has at most one document error view.

If the Snap fails during the operation, an error document is sent to the error view containing the fields error, reason, original, resolution, and stacktrace:

{ 
error: "Error parsing at line 2"
reason: "java.io.IOException: ..."
original:  {...} 
resolution: "Please provide valid CSV data at line 3 or route it to the error view"
stacktrace: "com.Snaplogic.Snap.api.SnapDataException:  ...
}

 


Settings

Label



Required. The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline.

Quote character


The Quote character property specifies the character to be used for a quote. As of 4.3.2, this property can be an expression, which is evaluated with the values from the pipeline Pipeline parameters.
Example:  “Format:  Character 

Note

Only a single character is allowed as a quote character.

Default value:  “
FormatExample:  Character  “


Delimiter

Required. The Delimiter property specifies the character to be used as a delimiter in parsing the CSV data. In case that tab is used as a delimiter, enter "\t" instead of pressing the Tab key. Any Unicode character is also supported.  As of 4.3.2, this property can be an expression, which is evaluated with the values from the pipeline parameters.
Example: \t, \u001 
Default value: , 
Format: Character or Unicode


Escape character

The escape character used when parsing rows. Only single characters are supported. As of 4.3.2, this property can be an expression, which is evaluated with the values from the pipeline parameters. Leave this property empty if no escape character is used in the input CSV data.
Example: \

Default value: \


Skip lines

Required. The Skip lines property specifies the number of lines in the input data to be skipped before the Snap starts parsing. 

Note

Skip lines support works well if it is less than or equal to the number of lines of the first partition. If it is larger than the number of lines of the first partition, only the first partition will be skipped.

Example: 0 
Default value: 0 
Format: Integer 

Contains header

The Contains header property specifies whether the input data contains the CSV header or not. 
Example: True 
Default value: True 
Format: Boolean 


Column names 

The Column names property is a composite table property, which contains the Columns property in it. This property is ignored if the second input view is used for the CSV metadata.

Columns

The Columns property specifies the list of columns to be used as a CSV header in formatting when the Contains header property is false. 
Example
  • Last Name 
  • First Name 
  • Street 
  • City 
  • State 

Default value[None] 


Validate headers


This option specifies whether or not the headers from the input data should be validated against the Column names table property. If this option is checked, the Snap throws an exception when they do not match exactly.
Default value: [None]

Header size error policy

Enables you to handle any header size errors, which occur when the number of values in a CSV line is larger than the header size. To handle header size errors, you can select any of the following options:

  • Trim record to fit header: The Snap sends the trimmed documents to the output view.
  • Fail if record is larger than header: The Snap sends the entire document to the error view. 
  • Both: The Snap sends the trimmed record to the output view and also sends the entire record to the error view.

Default value: Both

Header size error policy


This setting lets you decide how to handle the error. In the newly provided csv, the last record is to big. Possible values include:

  • Fail if record is larger than header, which sends the entire documents to the error view
  • Trim record to fit header, which sends the trimmed documents to the output view
  • Both, which sends the trimmed record to the output view and also the entire record to the error view.

Default value: Both


Character setThis setting lets you select the character set in which input CSV data is encoded. The supported selections are:
  • Auto BOM detect: The Snap attempts to detect BOM (Byte Order Mark) in the input CSV data. If no BOM is found, UTF-8 character set is used by default.
  • UTF-8
  • UTF-16LE
  • UTF-16BE
  • ISO-LATIN-1:  This character set is also called ISO-8859-1 and generally intended for Western European languages.

Default value: Auto BOM detect.


Ignore empty data

This property can be set false to produce an empty output document when the input CSV data is empty (both an empty binary stream and a binary stream with CSV headers only). This feature may be useful if the downstream Snaps should be executed whether the input CSV data is empty or not.

Default value: True

Preserve Surrounding Spaces

Select this checkbox to preserve the surrounding spaces for the values that are non-quoted. 

  • If you enable the expression icon when the check box checkbox is selected, then the value of this setting is set to true.
  • If you enable the expression icon when the check box checkbox is not selected, then the value of this setting is set to false.
Note

This setting is applicable only for unquoted data.

For example, if you are using data with a delimiter as follows:

NAME|AGE|GENDER
AA| 12| F
BB| 23| M

If you deselect the check boxthis checkbox, then surrounding spaces are removed before 12, 23, F, and M.

Multiexcerpt include macro
nameSnap Execution
pageAnaplan Read


Multiexcerpt include macro
nameSnap_Execution_Introduced
pageAnaplan Read



Note
You must either select Contains header or specify a Column name in order for validation on the pipeline to work.

Examples


Use Case

Using the CSV Parser Snap Schema Capability

One of the features in the CSV Parser which customers sometimes request is the ability to define the fields (and their data types) for incoming CSV files. This is made easy by adding a second input view to the CSV Parser Snap, and providing the definition of the fields, and their data types in the flow.


For example, if you have input data in my CSV file as follows, with no header line:


You can create a definition of the CSV data in another CSV file as follows:



Note the data types are optional, and defined on the second line of the input file.  The parser supports the use of 'string', 'integer', 'float' and 'boolean' types. String is the default data type, any empty data type fields are considered to be strings.

The configuration of the pipeline for this use is as follows:

where the Read Snaps are File Readers.

The CSV Parser is configured as follows:

 

with the View settings as:

 

The resulting data in the SnapLogic pipeline data flow looks like this:


Insert excerpt
Transform Snap Pack
Transform Snap Pack
nopaneltrue