CSV Data Stream Format

Sybase CEP Engine can use CSV Data Stream Format, which is compatible with the CSV data files format used by Microsoft Excel and many other applications.

The box below shows the valid syntax for the Data Stream. The syntax descriptions include characters (such as square brackets) that are not literals in this context but instead have special meanings. These special meanings are explained below:

Putting all this together, the following line

Tuple = [Field [ , Field ... ] ] NEWLINE

means that a tuple can have 0 fields, 1 field, or more fields, and if there is more than 1 field then the fields must be separated by commas. The Tuple must be terminated with a NEWLINE. For example, all of the following are valid values for Tuple:

col1

col1, col2

col1, col2, col3

Each of these would of course be terminated with a NEWLINE. An empty line terminated with a NEWLINE would also be valid.

Stream = [ Headers ] [ Tuple ]
Tuple = [ Field [ , Field ... ] ] NEWLINE
   
Note: Fields correspond to tuple field values.
NonEmptyTuple = Field [ , Field ... ]
Headers = <same as Tuple, but fields correspond to tuple field names.>
Field = [QUOTE] [ PLAIN_CHAR ...] [QUOTE] | 
  " [ (ANY_NONQT_CHAR | DOUBLEQUOTE) ... ] "
QUOTE = single quote (ascii 0x22) or double quote ascii 0x27). 
Note that if you start a quoted string with a particular type 
of quote, you must close with the same type of quote.  For example: 
these are invalid: 
    'Hi"
    "Bye'
DOUBLEQUOTE = '""' representing a single '"' within the field value.
ANY_NONQT_CHAR = <any ASCII character except for '"' (0x22) and 
    including line separators>
PLAIN_CHAR = <any printable ASCII char except ',' and '"',
   i.e. ASCII 0x21 and ASCII 0x23 - 0x7e>
NEWLINE = CR  |  LF  |  CR LF
CR = the Carriage Return character (0x0D)
LF = the Line Feed character (0x0A)

By default, Sybase CEP reads and writes the NEWLINE using the convention for the current platform, for example, CR LF for Microsoft Windows and LF for UNIX-like operating systems.

A LineEndCRLF format option may be used to specify the line ending. If the value of this option is 'true', CRLF line ending is used; if it is 'false', LF ending is used.

For example, the CSV trades stream can look like the following:

Timestamp,Symbol,Price,Volume\r\n
"2005/01/28 10:23:54",ABC,11.40,300000\r\n
"2005/01/28 10:23:55",XYZ,32.84,1260000\r\n"
"2005/01/28 10:24:06",XYZ,32.74,6300000\r\n
"2005/01/28 10:24:32",ABC,12.01,50000\r\n
...

The CSV Data Stream format has the following options:

Note that for input adapters:

For output adapters: