CSV loaders #
Small CSV helpers for TorchLean examples and runtime regression tests.
The parser is deliberately narrow: unquoted delimiter-separated numeric cells only. It does not
support quoted fields, escaped delimiters, locale-specific number formats, NaN, or inf.
Keeping that grammar explicit is better than accidentally treating this as a production CSV
library.
Options for the CSV parser in this module.
Limitations (by design): no quoted fields, no escaped delimiters, and no locale-aware number parsing.
- delimiter : Char
Delimiter character (default:
,). - skipHeader : Bool
If true, drop the first line before parsing rows.
- trimCells : Bool
If true, trim ASCII whitespace around cells and around each row.
- allowEmptyLines : Bool
If true, ignore empty lines (otherwise treat them as an error).
Instances For
Parse a numeric string into a Float.
Supported grammar:
- optional sign
- digits
- optional fractional part
.digits - optional scientific exponent
e±digits
This parser rejects NaN, inf, locale separators, and quoted CSV cells.
Instances For
Parse one CSV line into a list of floats.
Returns none for empty lines when allowEmptyLines = true.
Instances For
Read a CSV file into a list of float rows.
This helper is intended for small example datasets and smoke tests, not a full CSV implementation.
Instances For
Read a two-column CSV file into a dataset of pairs (x, y).
This is useful for small regression examples where each row is one training pair.
Instances For
Read an n-column CSV file into a dataset of length-n vectors.
Each row must have exactly n cells.