Cogitek RIATest 6 Documentation Copyright © Cogitek Inc.

CSVStream Object

CSVStream object is used for reading and writting CSV files. See how to use CSVStream objects for parametrization and data-driven testing. The implementation confirms to RFC 4180.

Methods

MethodDescription

CSVStream

new CSVStream(fileStream)
Create a CSVStream object and attach it to a FileStream.

getCharset

getCharset()
Returns current charset. Default is UTF-8.

getDelimiter

getDelimiter()
Returns current field delimiter character. Default is comma.

getEnclosure

getEnclosure()
Returns current field enclosure character. Default is double quote character.

getLineEnding

getLineEnding()
Returns current line ending. Default for Windows is CR-LF, for Mac is LF.

getTypeName

getTypeName()
Get the name of the object type.

hasOwnProperty

hasOwnProperty(propName)
Returns true if this object has a property with name equal to propName.

readLine

readLine()
Read and return a line of CSV file as an array of field values.

setCharset

setCharset(argument)
Set charset. See FileStream.writeMultibyte() for supported charsets.

setDelimiter

setDelimiter(argument)
Set field delimiter character. For example:
var fs = new FileStream();
fs.open("test.csv",FileMode.READ);
var csv = new CSVStream(fs);
csv.setDelimiter(":");
csv.writeLine([1234,"abc","abc:def"]);

setEnclosure

setEnclosure(argument)
Set field enclosure character.

setLineEnding

setLineEnding(argument)
Set line ending character(s). For example set line endings to CR-LF (Windows standard):
csv.setLineEnding("\r\n");

toPrintableString

toPrintableString(maxLevels)
Returns full string representation of the object. maxLevels parameter will control how many levels of sub-objects to print for nested objects.

writeLine

writeLine(lineValuesArray)
Write an array of values to CSV file. For example:
csv.writeLine([123,"abc"]);

Found a typo? Have a suggestion? Please submit your request here.