Module std::encoding::csv

CSV parsing โ€” pure Hew implementation.

Parse CSV data from strings or files into a table that can be queried by row/column index or column name.

Examples

import std::encoding::csv;

fn main() {
    let table = csv.parse("name,age\nAlice,30\nBob,25");
    let rows = table.rows();
    let name = table.get_by_name(0, "name");
    println(name);  // "Alice"
}

Contents

Functions

Function parse

pub fn parse(data: string) -> Table

Parse CSV data from a string (first row is treated as headers).

Function parse_no_headers

pub fn parse_no_headers(data: string) -> Table

Parse CSV data from a string without treating the first row as headers.

Function parse_file

pub fn parse_file(path: string) -> Table

Parse CSV data from a file path (first row is treated as headers).

Panics if the file cannot be read.

Traits

Trait TableMethods

Methods available on a CSV Table.

Methods

fn rows(self: Self) -> i64

Return the number of data rows (excluding the header row).

fn cols(self: Self) -> i64

Return the number of columns.

fn header(self: Self, col: i64) -> string

Return the header name for the given column index.

fn get(self: Self, row: i64, col: i64) -> string

Return the cell value at the given row and column index.

fn get_by_name(self: Self, row: i64, col_name: string) -> string

Return the cell value at the given row for the named column.

fn free(self: Self)

No-op for compatibility (struct tables don't need manual freeing).