Skip to main content

Read CSV

Synopsis

This Operator reads an ExampleSet from the specified CSV file.

Description

CSV is an abbreviation for Comma-Separated Values. The CSV files store data (both numerical and text) in plain-text form. All values corresponding to an Example are stored as one line in the CSV file. Values for different Attributes are separated by a separator character. The separator remains constant. Each row in the file uses the constant separator for separating Attribute values. The term 'CSV' suggests that the Attribute values would be separated by commas, but other separators can also be used.

The easiest way to import a CSV file is to use theImport Configuration Wizardfrom the Parameters panel. All parameters can also directly be set in the Parameters panel. For more details about the Operator, see the description of the parameters.

Please make sure that the CSV file is read correctly as an ExampleSet before building a Process that uses it.

Differentiation

There are manyRead<source>Operators in theData Accessgroup andFiles/Readsub-group. For example, there isRead Excel,Read URL,Read SPSS,Read XMLand other Operators, which can read ExampleSet from different file formats.

Input

file

A CSV file can be optionally passed in as a file object. This can be created with Operators having file output ports such as theRead FileOperator.

Output

output

This port delivers the ExampleSet created from the CSV file provided at the input port, imported through theImport Configuration Wizardor loaded from the path given to thecsv fileparameter.

Parameters

Import configuration wizard

This user-friendly wizard guides you to easily configure this Operator to import the CSV file.

Csv file

The path of the CSV file is specified here. It can also be selected using the 'Choose a file' button.

Column separators

Column separators for CSV files can be specified here. It can also be provided as a regular expression. A good understanding of regular expressions can be developed by studying the description of Select Attributes Operator and its tutorial Processes.

Trim lines

This parameter indicates if lines should be trimmed (removal of empty spaces at the beginning and the end) before the column split is performed. This option might be problematic if TABs ('\t') are used as separators.

Use quotes

This parameter indicates if quotes should be regarded. Quotes can be used to store special characters likecolumn separators. For example if (,) is set ascolumn separatorand (") is set asquotes character,然后一行(a, b, c, d)将被翻译成4 values for 4 columns. On the other hand ("a,b,c,d") will be translated as a single column value a,b,c,d. If this parameter is set to false, thequotes characterparameter and theescape characterparameter cannot be defined.

Quotes character

This parameter defines the quotes character and is only available ifuse quotesis set to true.

Escape character

This parameter specifies the character used to escape the quotes and is only available ifuse quotesis set to true. For example, if (") is used asquotes characterand ('\') is used asescape character, then ("yes") will be translated as (yes) and (\"yes\") will be translated as ("yes").

Skip comments

这个参数是用来忽略评论CSV file (if any). If this option is set to true, a comment character should be defined using thecomment charactersparameter.

Comment characters

This parameter is available ifcomment charactersis set to true. Lines beginning with these characters are ignored. If this character is present in the middle of the line, anything that comes in that line after this character is ignored. Thecomment characteritself is also ignored.

Parse numbers

This parameter specifies whether numbers are parsed or not.

Decimal character

This character is used as the decimal character.

Grouped digits

This parameter decides whether grouped digits should be parsed or not. If this parameter is set to true, agrouping characterparameter has to be specified.

Grouping character

This character is used as the grouping character. If this character is found between numbers, the numbers are combined and this character is ignored. For example if "22-14" is present in the CSV file and "-" is set as thegrouping character, then "2214" will be stored.

Infinity string

This parameter can be set to parse a specific infinity representation (e.g. "Infinity"). If it is not set, the local specific infinity representation will be used.

Date format

The parameter specifies the date and time format. Many predefined options exist but users can also specify a new format. If text in a CSV file column matches this date format, that column is automatically converted to date type.

Some corrections are automatically made on invalid date values. For example, a value '32-March' will automatically be converted to '1-April'.

Columns containing values which cannot be interpreted as numbers will be interpreted as nominal, as long as they do not match the date and time pattern of the date format parameter. If they match, this column of the CSV file will be automatically parsed as date and the corresponding Attribute will be of type date.

First row as names

If this parameter is set to true, it is assumed that the first line of the CSV file has the names of the Attributes. If so, the Attributes are automatically named and the first line of the CSV file is not treated as a data line.

Annotations

If thefirst row as namesis not set to true, annotations can be added using the 'Edit List' button of this parameter, which opens a new menu. This menu allows you to select any row and assign an annotation to it. Name, Comment and Unit annotations can be assigned. If row 0 is assigned a Name annotation, it is equivalent to setting thefirst row as namesparameter to true. If you want to ignore any row, you can annotate them as Comment. Remember that row number in this menu does not count commented lines.

Time zone

Users can select any time zone from the list of provided time zones.

Locale

Users can select any locale from the list of provided locales.

Encoding

Users can select any encoding from the list of provided encodings.

Read all values as polynominal

This option allows you to disable the type handling for this operator. Every column will be read as a polynominal attribute.

Data set meta data information

This parameter allows to adjust or override the meta data of the CSV file. Column index, name, type and role can be specified here.

The Read CSV Operator automatically tries to determine an appropriate data type of the Attributes by reading the first few lines and checking the occurring values. Integer values are assigned the integer data type, real values the real data type. Values which cannot be interpreted as numbers are assigned the nominal data type, as long as they do not match the format of thedate formatparameter.

With thedata set meta data informationparameter, this automatic assignment can be adjusted or overwritten.

Read not matching values as missings

If this parameter is set to true, values that do not match with the expected value type are considered as missing values and are replaced by '?'. For example, if 'abc' is written in an integer column, it will be treated as a missing value. A question mark (?) in the CSV file is also read as a missing value.

Data management

This parameter determines how the data is represented internally. Users can select any option from the provided list.