base.Channel.setDelimiter
Define the value delimiter for a channel.
Syntax
setDelimiter(
delimiter STRING )
- delimiter is the value delimiter to be used.
Usage
After creating the channel object, define the field value delimiter with the
setDelimiter()
method.CALL ch.setDelimiter("^")
The default delimiter is defined by the DBDELIMITER
environment variable, or a pipe (|
) if DBDELIMITER is not defined.
Specify
CSV
as the delimiter to read/write in Comma Separated Value format:
CALL ch.setDelimiter("CSV")
Specify
TSV
as the delimiter to read/write in TAB Separated Value format:
CALL ch.setDelimiter("TSV")
Important: Setting a
NULL
delimiter is allowed for backward
compatibility, but must be avoided. This was a workaround to read/write complete lines. If the
delimiter is set to NULL
, the read()
and write()
methods do not use the backslash (\
) escape character. As a result, data with
special characters like backslash, delimiter or line-feed will be written as is, and reading data
will ignore escaped characters in the source stream. If you need to read or write non-formatted
data, it is recommended that you use the
readLine()
/
writeLine()
methods instead. These methods do not use a delimiter, nor do they use
the backslash escape character.Rules for CSV/TSV format
The CSV (Comma Separated Values) or TSV (TAB Separated Values) format rules for stringification is similar to the default format when using a regular single-character delimiter, with the following differences:
- Values might be surrounded with
"
double quotes. - Leading and trailing blanks are kept (no truncation).
- No ending delimiter is expected at the end of the input record.
- With CSV, a comma character in the value is not be escaped, and the value must be double-quoted.
- With TSV, a TAB character in the value is not be escaped, and the value must be double-quoted.
- A NEWLINE character in the value is not be escaped, and the value must be double-quoted.
- A double-quote character in the value must be doubled, and the value must be double-quoted.
- A
\
backslash characters in the value is not escaped, and the value must be double-quoted.