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.
CsvColumn
CSV column
Operations
Average #
Calculates the column average
method : public : Average() ~ FloatReturn
| Type | Description |
|---|---|
| Float | column average |
Example
csv := CsvTable->New("score,grade\r\n80,B\r\n90,A\r\n70,C");
col := csv->ColumnValues("score");
Console->PrintLine(col->Average());Average #
Calculates the column average
method : public : Average(end:Int) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| end | Int | ending column |
Return
| Type | Description |
|---|---|
| Float | column average |
Average #
Calculates the column average
method : public : Average(start:Int, end:Int) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| start | Int | starting column |
| end | Int | ending column |
Return
| Type | Description |
|---|---|
| Float | column average |
Get #
Gets the indexed row value
method : public : Get(index:Int) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| index | Int | index |
Return
| Type | Description |
|---|---|
| String | row value |
Example
csv := CsvTable->New("city,pop\r\nParis,2M\r\nLondon,9M");
col := csv->ColumnValues("city");
col->Get(0)->PrintLine();Median #
Calculates the column median
method : public : Median() ~ FloatReturn
| Type | Description |
|---|---|
| Float | column median |
Example
csv := CsvTable->New("val,tag\r\n1,a\r\n3,b\r\n5,c\r\n7,d");
col := csv->ColumnValues("val");
Console->PrintLine(col->Median());New # constructor
Constructor
New(rows:Vector<String>)Parameters
| Name | Type | Description |
|---|---|---|
| rows | Vector<String> | row values |
Size #
Gets the row size
method : public : Size() ~ IntReturn
| Type | Description |
|---|---|
| Int | row size |
Example
csv := CsvTable->New("x,y\r\n1,2\r\n3,4\r\n5,6");
col := csv->ColumnValues("x");
Console->PrintLine(col->Size());Sum #
Calculates the column sum
method : public : Sum() ~ FloatReturn
| Type | Description |
|---|---|
| Float | column sum |
Example
csv := CsvTable->New("a,b\r\n10,20\r\n30,40");
col := csv->ColumnValues("a");
Console->PrintLine(col->Sum());