Comma-Separated Values (CSV): Read From CSV File Adapter.

A Read From CSV File adapter reads Rows from a CSV file.

Property Name (screen)

Property Name (Attach Adapter)

Type

Description

Filename

Filename

String

The name and path of the CSV file to read data from. Specify a file name and path either by typing it in or by clicking on the Browse button for this field. The CSV file name definition follows the format defined by regular expression. By default, the path is relative to the server's adapters base folder and must be underneath that base folder, but you can use $ProjectFolder to specify a path relative to the project folder. For more information, see Setting The Base Folder For File Input/Output Adapters. For details about the Browse and Edit buttons to the right of the filename, see the discussion following this table.

Loop count

LoopCount

Integer Min: 0 Max: 2000000000 Default: 1

If the Loop Count is greater than 1, the data will be sent the specified number of times. After the adapter finishes reading the file, the adapter will start reading again from the beginning. If the Loop Count is 1, the file is read only once and the adapter stops sending data once the end of file is reached. If the Loop Count is 0, the file is read continuously. If the loop count is left blank, it will default to 1.

Rate

Rate

Float Min: 0.000001

If this property is non-zero, the adapter reads data from the input file at the specified rate per second. Any row timestamps in the input file are not be used to determine the time at which rows are sent.

This property takes precedence over the "File has timestamp column" property. The default is to leave this unset, in which case the row timestamp determines the relative timing at which rows are sent.

Set timestamp to current time

UseCurrentTimestamp

Boolean Default: false

If true, the adapter overrides the row timestamp specified in the file with the current system time.

File has timestamp column

TimestampColumn

Boolean Default: true.

Every row must have a row timestamp that indicates the time the row was created. You can set the row timestamp in the input data (for example, in the CSV file), or this timestamp can be set by the adapter at the time that the row is sent to the server.

If "File has timestamp column" is true, the adapter assumes that the first field in each row contains a row timestamp. If this flag is set to false, the adapter inserts the current time into the row timestamp field before sending the row. Note: The column with the row timestamp is not explicitly listed in the schema. See the discussion of "row timestamp" in the Sybase CEP Programmer's Guide for more information about row timestamps.

Timestamp column format

TimestampColumnFormat

String

If "File has timestamp column" is set to true, the Timestamp column format specifies the format of that row timestamp column, e.g. 'YYYY/MM/DD HH24:MI:SS.FF TZD'. If no timestamp format is specified, the adapter assumes that the timestamp is represented as a number of microseconds since 00:00:00 Jan 1, 1970 UTC/GMT.

If you specify a format specifier, this format specifier applies only to the row timestamp column; it does not apply to all input columns of type TIMESTAMP. For more information, see Reading, Writing, and Converting Timestamps.

Timestamp Base

TimestampBase

Timestamp

If this property is set, when the adapter starts, it behaves as though it has started at the time specified by the Timestamp base. This affects the time that the first row in the input file is sent. For example, if the Timestamp base is 2006-02-01 09:00:00 and the row timestamp of the first row in the input file is 2006-02-01 09:00:05 (in other words, 5 seconds after the timestamp base), the adapter will not send the first row until 5 seconds after the adapter was started regardless of what time the adapter was actually started. This can be used to help synchronize data in multiple streams. If this property is left blank, the first row will be sent immediately after the adapter module starts.

File Has A Title Row

TitleRow

Boolean Default: false

If this flag is true, the adapter assumes that the first line in the file contains column names, in which case the adapter tries to match the column names in the file with the column names in the stream's schema. If this flag is set to false, the adapter assumes that the first line in the file contains a row of data, in which case the order of the CSV columns must be the same as the order of the Row descriptor fields.

Field Separator Character

CsvDelimiterString

String Default: , (comma)

This indicates which character(s) separate the fields in the file. In most cases, this should be left at the default value, which is a comma. However, you can specify different separator character(s), such as a vertical pipe symbol ("|") and so on. If you specify multiple characters, each of those characters is treated as a separator; the adapter does not look for a multi-character separator.

Line Continuation Character

CsvLineContinuationCharacter

String Default: ^ (caret)

If a single row of data must be split across multiple input lines, you can specify a line continuation character that tells the adapter to treat the multiple lines as a single row. By default, this line continuation character is the caret ("^") symbol. Note that this character is treated as the line continuation character only if it is the last non-whitespace character preceding a newline. See the discussion below for an example. If you specify multiple characters, each of those characters is treated as a line continuation character; the adapter does not look for a multi-character line-continuation indicator. If the line continuation field is empty, no line continuation will be possible in the CSV file. This allows data with wildly varying input characters to be properly processed.

String Quote Characters

CsvQuoteCharacters

String Default: ' (single quote) and " (double quote)

By default, both the single quote and the double quote characters may be used to delimit a string. If you specify multiple characters, each of those characters is treated as a quote character; the adapter does not look for a multi-character quote indicator. If the string is started with a double quote character, it must end with a double quote character, and single quote characters within that string are treated as regular characters rather than as the end of the string. Similarly, if the string is started with a single quote character, it must end with a single quote character, and any double quote characters within the string are treated as normal characters. If you change the defaults, only the character(s) that you specify are treated as quote characters.

NULL string value

CsvNullString

String Default: NULL

This allows you to specify what value indicates a NULL value in the file. The value should not be quoted. If the NULL string value is the word NULL (without quotes), the value "NULL" (with quotes) is a 4-letter string, not an indication that you want to use a NULL value. If you do not specify a NULL string value, then an "empty" string field where there is nothing between the field separator characters for that field is treated as NULL.

Line Terminator Character

CsvLineTerminatorChar

String Default: \n

This allows you to specify what character represents the end-of-line character. You specify the character in one of the following ways:

\n This 2-character sequence represents the Line Feed character (ASCII 10).

\r This 2-character sequence represents the Carriage Return character (ASCII 13). \t

<any printable char> This 1 character may be any printable character except the backslash. Enter the character without any quotation marks and without any leading backslash.

\x## , where "#" represents a hexadecimal digit (0-9, A-F). To indicate that you want to use ctrl-Z as the end-of-line character, you would specify the 4-character sequence \x26 .

Escape Characters

CsvEscapeCharacters

String Default: \

The characters used to escape the special meaning of other characters, such as column separators and quotes.

Enable DL (Dynamic Loading)

EnableDynamicLoading

Boolean Default: False

When checked, the CSV input adapter uses a dynamic loading function. When unchecked, the CSV input adapter uses the original behavior to read data from a specified file. When enabled, the Filename is ignored.

DL Source Directory

Source Directory

String

The full path of source directory where the CSV file(s) get dynamically loaded into the CSV adapter.

DL File Name Format

DLFileNameFormat

String

The regular expression definition for the CSV file names to be loaded up.

DL Check Interval

CheckInterval

Long Min: 1 Default: 60

The next check interval for the adapter when no more files need to be processed, in seconds.

Note: The CSV files will be loaded up periodically from an accessible folder that has been predefined, in the order of the creation date time stamp.

Each input stream has a property that can specify whether to use the current server timestamp value instead of the row timestamp set by the adapter (see the stream's Properties tab in ). If this stream property is set to true, it overrides any row timestamp set by the adapter.

The Adapter Properties screen in Sybase CEP Studio allows you to specify an input path and file name for the file by clicking the Browse button and identifying the file. The path is relative to the adapters base folder, either as specified for Sybase CEP Server running on the same computer as Sybase CEP Studio, or as specified in the preferences for Sybase CEP Studio. For more information, see Setting The Base Folder For File Input/Output Adapters. In order for this feature to work properly, make sure that the Adapter's Base Folder field in Sybase CEP Studio Settings is set to the same folder as the adapters base folder for Sybase CEP Server. The Base Folder setting for the Sybase CEP Server is specified during the installation process, and can be changed in Sybase CEP Server's c8-server.conf file. The base folder setting for Sybase CEP Studio can be set from the Tools->Settings command on the Sybase CEP Studio menu.

The Edit button opens an editor that will allow you to edit any file whose name you enter into the filename field. This allows you to correct errors in the data. If the file's extension is "csv" or "xml", Sybase CEP Studio opens the appropriate editor specified in the "External Tools" tab available from the menu item "Tools -> Settings". For files with other extensions, on Microsoft Windows the editor is the one specified by the operating system's file associations. On UNIX-like operating systems, Sybase CEP Studio opens the editor specified by the EDITOR environment variable.

Note:

When you click the Edit button, Sybase CEP Studio will look for the file in the SybaseC8Repository, even if the adapters base folder is set to another location. you can need to use the Browse button (adjacent to the Edit button) to navigate to the desired directory before you try to edit the file.