v2026.11.3
All Bundles
Bundle

CSV reading and writing. CsvTable parses delimited text (RFC 4180: quoted fields may hold the delimiter, line breaks and doubled quotes) into CsvRow records and CsvColumn values, reports the first malformed row through GetError(), and writes CSV back out with ToString() or CsvTable->FormatRow(). The delimiter defaults to a comma and can be set per table. Compile with -lib csv.

CsvRow

CSV row

Example

csv := CsvTable->New(FileReader->ReadFile("data.csv"));
row := csv->Get(0);
row->Get(0)->PrintLine();       # by index
row->Get("name")->PrintLine();  # by column name
row->Size()->PrintLine();       # column count

Operations

Append #

Appends value to the end of the row

method : public : Append(value:String) ~ Nil

Parameters

NameTypeDescription
valueStringto append

Example

csv := CsvTable->New("name,age\r\nAlice,30");
row := csv->Get(1);
row->Append("engineer");
Console->PrintLine(row->Size());

Average #

Calculates the row average

method : public : Average() ~ Float

Return

TypeDescription
Floatrow average

Example

csv := CsvTable->New("a,b,c\r\n10,20,30");
row := csv->Get(1);
Console->PrintLine(row->Average());

Average #

Calculates the row average

method : public : Average(end:Int) ~ Float

Parameters

NameTypeDescription
endIntending column

Return

TypeDescription
Floatrow average

Average #

Calculates the row average

method : public : Average(start:Int, end:Int) ~ Float

Parameters

NameTypeDescription
startIntstarting column
endIntending column

Return

TypeDescription
Floatrow average

Get #

Gets the indexed row value

method : public : Get(index:Int) ~ String

Parameters

NameTypeDescription
indexIntindex

Return

TypeDescription
Stringrow value

Example

csv := CsvTable->New("name,age\r\nAlice,30\r\nBob,25");
row := csv->Get(1);
row->Get(0)->PrintLine();
row->Get(1)->PrintLine();

Get #

Gets the indexed row value

method : public : Get(name:String) ~ String

Parameters

NameTypeDescription
nameStringname

Return

TypeDescription
Stringrow value

Example

csv := CsvTable->New("name,age\r\nAlice,30\r\nBob,25");
row := csv->Get(1);
row->Get("name")->PrintLine();
row->Get("age")->PrintLine();

Id #

Gets the row ID

method : public : Id() ~ Int

Return

TypeDescription
Intid

Example

csv := CsvTable->New("name,age\r\nAlice,30\r\nBob,25");
row := csv->Get(1);
Console->PrintLine(row->Id());

Median #

Calculates the row median

method : public : Median() ~ Float

Return

TypeDescription
Floatrow median

Example

csv := CsvTable->New("a,b,c,d\r\n1,3,5,7");
row := csv->Get(1);
Console->PrintLine(row->Median());

New # constructor

Constructor

New(table:CsvTable, id:Int, read_only:Bool, columns:CompareVector<String>)

Parameters

NameTypeDescription
tableCsvTabletable that has row
idIntrow id
read_onlyBooltrue if readonly, false otherwise
columnsCompareVector<String>column values

Set #

Sets the indexed row value

method : public : Set(index:Int, value:String) ~ Bool

Parameters

NameTypeDescription
indexIntindex
valueStringvalue to set

Return

TypeDescription
Booltrue of value was set, false otherwise

Example

csv := CsvTable->New("name,score\r\nAlice,0\r\nBob,0");
row := csv->Get(1);
row->Set(1, "95");
row->Get(1)->PrintLine();

Set #

Sets the named row value

method : public : Set(name:String, value:String) ~ Bool

Parameters

NameTypeDescription
nameStringname
valueStringvalue

Return

TypeDescription
Booltrue of value was set, false otherwise

Example

csv := CsvTable->New("name,score\r\nAlice,0\r\nBob,0");
row := csv->Get(1);
row->Set("score", "88");
row->Get("score")->PrintLine();

Size #

Gets the row size

method : public : Size() ~ Int

Return

TypeDescription
Introw size

Example

csv := CsvTable->New("a,b,c\r\n1,2,3");
row := csv->Get(1);
Console->PrintLine(row->Size());

Sum #

Calculates the row sum

method : public : Sum() ~ Float

Return

TypeDescription
Floatrow sum

Example

csv := CsvTable->New("a,b,c\r\n10,20,30");
row := csv->Get(1);
Console->PrintLine(row->Sum());

Sum #

Calculates the row sum

method : public : Sum(end:Int) ~ Float

Parameters

NameTypeDescription
endIntending column

Return

TypeDescription
Floatrow sum

Sum #

Calculates the row sum

method : public : Sum(start:Int, end:Int) ~ Float

Parameters

NameTypeDescription
startIntstarting column
endIntending column

Return

TypeDescription
Floatrow sum

ToJson #

Formats the row into a JSON object string

method : public : ToJson() ~ String

Return

TypeDescription
StringJSON object string

Example

csv := CsvTable->New("name,age\r\nAlice,30");
row := csv->Get(1);
row->ToJson()->PrintLine();

ToString #

Formats the row as one CSV record: every field is quoted, a quote inside a field is doubled, and fields are separated by the table's delimiter. CsvTable parses the result back to the same values.

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation of the row

Example

csv := CsvTable->New("name,age\r\nAlice,30");
row := csv->Get(1);
row->ToString()->PrintLine();