Skip to main content

csv functions

build#

The build function takes the list as input and returns the csv string.

Syntax:

csv().build(List list);

Returns: String

Example:

header = ["name","age","gender"];value1 = ["June","24","Female"];value2 = ["John","27","Male"];list = [header,value1,value2];csvString = csv().build(list);log csvString;//"name","age","gender"//"June","24","Female"//"John","27","Male"

parse#

The parse function takes the csv String as input and converts it to list and returns it.

Syntax:

csv().parse(String csvString);

Returns: List

Example:

log csv().parse(csvString); //[[name, age, gender], [June, 24, Female], [John, 27, Male]]

parseAsMap#

The parse function takes the csv String as input and converts it to map and returns it.

Syntax:

csv().parseAsMap(String csvString);

Returns: Map

Example:

csvMap = csv().parseAsMap(csvString);log csvMap; //[{gender=Female, name=June, age=24}, {gender=Male, name=John, age=27}]

buildWithMap#

The buildWithMap function takes the Map as input and returns csv string.

Syntax:

csv().buildWithMap(Map csvMap);

Returns: String

Example:

csvMap = csv().buildWithMap(csvMap);log csvMap; //"gender","name","age"//"Female","June","24"//"Male","John","27"