CSV Loader #
Small CSV helpers for TorchLean examples and regression tests.
The parser is kept 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.
The parser accepts unquoted numeric fields with literal delimiters and locale-independent number syntax.
- delimiter : Char
Delimiter character (default:
,). - skipHeader : Bool
If true, drop the first line before parsing rows.
- trimCells : Bool
Trim rows before empty-line detection and cells before empty-cell detection. Numeric conversion accepts surrounding ASCII whitespace even when this option is false.
- 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
Surrounding ASCII whitespace is accepted independently of CsvOptions.trimCells.
This parser rejects NaN, inf, locale separators, and quoted CSV cells.
Instances For
Parse one CSV line into an array of floats.
Returns none for empty lines when allowEmptyLines = true.
Instances For
Read a CSV file into an array of float rows.
This helper is intended for compact example datasets and runtime checks, not a full CSV implementation.