v2026.5.3
All Bundles
Bundle CSV parsing and generation. CsvParser reads delimited text into typed rows and columns; CsvWriter builds CSV output. Supports custom delimiters and quoted fields. Compile with -lib csv.

CsvTable

CSV table

csv := CsvTable->New(FileReader->ReadFile("data.csv"));
if(csv->IsParsed()) {
   each(i : csv) {
      row := csv->Get(i);
      row->Get(0)->PrintLine();
   };
};

Operations

AppendColumn #

Appends a column to the end of the table

method : public : AppendColumn(name:String) ~ Bool

Parameters

NameTypeDescription
nameStringname of column to add

Return

TypeDescription
Booltrue if column was added, false otherwise

Example

csv := CsvTable->New("name,age\r\nAlice,30\r\nBob,25");
csv->AppendColumn("score");
Console->PrintLine(csv->RowSize());

ColumnValues #

Get values for a given row

method : public : ColumnValues(index:Int) ~ CsvColumn

Parameters

NameTypeDescription
indexIntcolumn index

Return

TypeDescription
CsvColumnvalues for the given row

Example

csv := CsvTable->New("name,score\r\nAlice,90\r\nBob,85");
col := csv->ColumnValues(1);
Console->PrintLine(col->Sum());

ColumnValues #

Get values for a given row

method : public : ColumnValues(name:String) ~ CsvColumn

Parameters

NameTypeDescription
nameStringcolumn name

Return

TypeDescription
CsvColumnvalues for the given row

Example

csv := CsvTable->New("name,score\r\nAlice,90\r\nBob,85");
col := csv->ColumnValues("score");
Console->PrintLine(col->Average());

Contains #

Searches a given column for like values

method : public : Contains(name:String, value:String) ~ CsvTable

Parameters

NameTypeDescription
nameStringcolumn name
valueStringvalue to search for

Return

TypeDescription
CsvTabletable of like results

Example

csv := CsvTable->New("name,role\r\nAlice,Engineer\r\nBob,Manager\r\nCarol,Engineering Lead");
results := csv->Contains("role", "Engin");
Console->PrintLine(results->Size());

Contains #

Searches a given column for like values

method : public : Contains(index:Int, value:String) ~ CsvTable

Parameters

NameTypeDescription
indexIntcolumn index
valueStringvalue to search for

Return

TypeDescription
CsvTabletable of like results

CountContains #

Counts a column for like values

method : public : CountContains(name:String, value:String) ~ Int

Parameters

NameTypeDescription
nameStringcolumn name
valueStringvalue to search for

Return

TypeDescription
Intnumber of occurrences

Example

csv := CsvTable->New("name,role\r\nAlice,Engineer\r\nBob,Manager\r\nCarol,Senior Engineer");
count := csv->CountContains("role", "Engineer");
Console->PrintLine(count);

CountContains #

Counts a column for like values

method : public : CountContains(index:Int, value:String) ~ Int

Parameters

NameTypeDescription
indexIntcolumn index
valueStringvalue to search for

Return

TypeDescription
Intnumber of occurrences

CountMatches #

Counts a column for matching values

method : public : CountMatches(name:String, value:String) ~ Int

Parameters

NameTypeDescription
nameStringcolumn name
valueStringvalue to search for

Return

TypeDescription
Intnumber of occurrences

Example

csv := CsvTable->New("name,dept\r\nAlice,Eng\r\nBob,HR\r\nCarol,Eng");
count := csv->CountMatches("dept", "Eng");
Console->PrintLine(count);

CountMatches #

Counts a column for matching values

method : public : CountMatches(index:Int, value:String) ~ Int

Parameters

NameTypeDescription
indexIntcolumn index
valueStringvalue to search for

Return

TypeDescription
Intnumber of occurrences

Delete #

Removes a row from the table

method : public : Delete(id:Int) ~ Bool

Parameters

NameTypeDescription
idIntrow to delete

Return

TypeDescription
Booltrue if deleted false otherwise

Example

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

Get #

Gets an indexed row

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

Parameters

NameTypeDescription
indexIntindex

Return

TypeDescription
CsvRowrow

Example

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

GetHeaders #

Gets header names

method : public : GetHeaders() ~ CsvRow

Return

TypeDescription
CsvRowheader names

Example

csv := CsvTable->New("name,age,city\r\nAlice,30,NY");
headers := csv->GetHeaders();
headers->Get(0)->PrintLine();
headers->Get(1)->PrintLine();

GetRowId #

Gets row name

method : public : GetRowId(name:String) ~ Int

Parameters

NameTypeDescription
nameStringname

Return

TypeDescription
Introw index

Example

csv := CsvTable->New("name,age,city\r\nAlice,30,NY");
Console->PrintLine(csv->GetRowId("age"));

IsParsed #

Returns rather the file has been successfully parsed

method : public : IsParsed() ~ Bool

Return

TypeDescription
Booltrue if successfully parsed, false otherwise

Example

csv := CsvTable->New("name,age\r\nAlice,30");
if(csv->IsParsed()) {
  "parsed ok"->PrintLine();
};

Matches #

Searches a given column for matching values

method : public : Matches(name:String, value:String) ~ CsvTable

Parameters

NameTypeDescription
nameStringcolumn name
valueStringvalue to search for

Return

TypeDescription
CsvTabletable of matching results

Example

csv := CsvTable->New("name,dept\r\nAlice,Eng\r\nBob,HR\r\nCarol,Eng");
results := csv->Matches("dept", "Eng");
Console->PrintLine(results->Size());

Matches #

Searches a given column for matching values

method : public : Matches(index:Int, value:String) ~ CsvTable

Parameters

NameTypeDescription
indexIntcolumn index
valueStringvalue to search for

Return

TypeDescription
CsvTabletable of matching results

New # constructor

Constructor

New(data:String)

Parameters

NameTypeDescription
dataStringCSV data with CRNL line endings

Example

csv := CsvTable->New("name,age\r\nAlice,30\r\nBob,25");
if(csv->IsParsed()) {
  Console->PrintLine(csv->Size());
};

New # constructor

Constructor

New(data:String, ending:String)

Parameters

NameTypeDescription
dataStringCSV data
endingStringline ending

Example

csv := CsvTable->New("name,age\nAlice,30\nBob,25", "\n");
if(csv->IsParsed()) {
  Console->PrintLine(csv->Size());
};

RowSize #

Gets the size of rows

method : public : RowSize() ~ Int

Return

TypeDescription
Introw size

Example

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

Size #

Gets the number of rows

method : public : Size() ~ Int

Return

TypeDescription
Intnumber of rows

Example

csv := CsvTable->New("name,age\r\nAlice,30\r\nBob,25\r\nCarol,28");
Console->PrintLine(csv->Size());

ToJson #

Formats the table into a JSON object string

method : public : ToJson() ~ String

Return

TypeDescription
StringJSON object string

Example

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

ToString #

Formats the table into a string

method : public : ToString() ~ String

Return

TypeDescription
Stringstring representation of the table

Example

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

UniqueColumnValues #

Get unique values for a given row

method : public : UniqueColumnValues(name:String) ~ CsvColumn

Parameters

NameTypeDescription
nameStringcolumn name

Return

TypeDescription
CsvColumnunique values for the given row

Example

csv := CsvTable->New("name,dept\r\nAlice,Eng\r\nBob,HR\r\nCarol,Eng");
uniq := csv->UniqueColumnValues("dept");
Console->PrintLine(uniq->Size());

UniqueColumnValues #

Get unique values for a given row

method : public : UniqueColumnValues(index:Int) ~ CsvColumn

Parameters

NameTypeDescription
indexIntcolumn index

Return

TypeDescription
CsvColumnunique values for the given row