csv feature

CSV Feature

Version: 17.07

Supported Since: 17.07

CSV Feature

CSV Feature provides the functionalities related to CSV message format such as inserting rows, updating values, retrieving columns, retrieving rows, and converting to JSON format.

APIs Java Docs

getRowCount

Parameters
XMessage message

The Message containing the CSV payload

boolean skipFirstRecord

Whether to skip the first record or not, assuming it can be a header record

Returns
int

Returns the row count of the CSV payload in the message

Returns the row count of the CSV payload in the message. With skipFirstRecord set to true, the row count will be returned neglecting the first record of the payload

getColumnCount

Parameters
XMessage message

The Message containing the CSV payload

Returns
int

Returns the column count of the CSV payload in the message

Returns the column count of the CSV payload. The column count will be calculated by considering the first row of the CSV payload

extractHeader

Parameters
XMessage message

The Message containing the CSV payload

Returns
List<String>

The header of the CSV message

Extracts the header of the CSV payload in the message. This method assumes that header row cannot contain values like ["ID, name", ""group, hall""]

getRows

Parameters
XMessage message

The Message containing the CSV payload

boolean skipFirstRecord

Whether to skip the first record or not, assuming it can be a header record

boolean setAsPayload

Whether to set the CSVMessageFormat which contains the returned list as the payload

Returns
List<String[]>

Returns the rows of the CSV payload in the message context

Returns all the rows of the CSV payload. First row can be neglected by setting skipFirstRecord as true. By setting the setAsPayload as true the returned List<String[]> will be set as the payload of the message

getRow

Parameters
XMessage message

The Message containing the CSV payload

int index

Zero-based position of the row

Returns
List<String>

The row which is at the position of index

Returns the row at index position. The returned list is not backed by the message payload, so that changes done to the list will not be reflected in the payload

getRowAsStringArray

Parameters
XMessage message

The Message containing the CSV payload

int index

Zero-based position of the row

Returns
String[]

The row which is at the position of index

Returns the row related to the <code>index</code> in an array format. The returned String[] is not backed by the message payload, so that changes done to the String[] array will not be reflected in the payload

extractValue

Parameters
XMessage message

The Message containing the CSV payload

int row

Zero-based position of the row

int column

Zero-based position of the column

Returns
String

The value in string format

Extracts the value at the given position (row, column) as a string from the CSV payload.

extractTypedValue

Parameters
XMessage message

The Message containing the CSV payload

int row

Zero-based position of the row

int column

Zero-based position of the column

Class<T> classType

Type of the the value

Returns
<T> T

The value in T format

Extracts the value at the given position (row, column) of the CSV payload.

appendRow

Parameters
XMessage message

The Message containing the CSV payload

List<String> record

The row which should be appended to the CSV payload

Inserts a row to the end of the CSV payload

insertRow

Parameters
XMessage message

The Message containing the CSV payload

List<String> record

The row which should be inserted to the CSV payload

int position

Zero-based position where the row should be inserted

Inserts a row to the given position of the CSV payload

replaceRow

Parameters
XMessage message

The Message containing the CSV payload

List<String> record

The row which should replace the row at replacePosition in the CSV payload

int replacePosition

Zero-based position of the row which should be replaced by the new record

Replaces the row by given record at the given replacePosition

updateValue

Parameters
XMessage message

The Message containing the CSV payload

int row

Zero-based position of the row

int column

Zero-based position of the column

String value

Value that should replace the old value

<T> T

Type of the value

Updates the value at given position (row, column) of the CSV payload by a string value

updateColumn

Parameters
XMessage message

The Message containing the CSV payload

int column

Zero-based position of the column

List<String> columnValues

New column values

boolean skipFirstRow

Whether to skip the first row of the CSV payload

Updates the column with values from columnValues. Size of columnValues should be the same as the number of rows in the CSV payload, or one less than it if `skipFirstRow is set to true.

removeRow

Parameters
XMessage message

The Message containing the CSV payload

int index

Zero-based position of the row

Returns
List<String>

The removed row of the CSV payload

Removes the row from the the CSV payload

removeColumn

Parameters
XMessage message

The Message containing the CSV payload

int column

Zero-based position of the column

Removes the column at position index from the payload

getColumn

Parameters
XMessage message

The Message containing the CSV payload

int column

Zero-based position of the column

boolean skipFirstRecord

Whether to skip the first record or not

Returns
List<String>

The column of the CSV payload

Returns the column at the position index. By setting skipFirstRow as true, the first row of the column can be discarded. If the CSV record has a null value, then empty string will be added to the list. The returned list is not backed by the message payload, so that changes done to the list will not be reflected in the payload

getColumn

Parameters
XMessage message

The Message containing the CSV payload

int column

Zero-based position of the column

boolean skipFirstRecord

Whether to skip the first record or not

Class<T> classType

Type of the column value

Returns
<T> T

The column of type T as a List<T>

Returns the column in the CSV payload in T type. First row of the column can be discarded by setting skipFirstRecord as true. The returned list is not backed by the message payload, so that changes done to the list will not be reflected in the payload

convertToJSON

Parameters
XMessage message

The Message containing the CSV payload

Converts the CSV file to a JSON format. The first row of the CSV payload is assumed to be the header row

In this topic
In this topic
Contact Us