Csv Parser¶
| Spice | |
|---|---|
CsvParser struct¶
Parser for CSV (comma-separated values) input.
Supports quoted fields, embedded delimiters/newlines and escaped quotes (by doubling, e.g. "" inside a quoted field yields a single "). Both \n and \r\n are accepted as line terminators.
The matching serializer lives in "std/text/csv-serializer".
Constructors¶
ctor¶
| Spice | |
|---|---|
Construct a CSV parser with the given control characters
Parameters
| Name | Type | Description |
|---|---|---|
delimiter |
char |
Field delimiter character (default: DEFAULT_DELIMITER) |
quote |
char |
Quote character used to wrap fields (default: DEFAULT_QUOTE) |
Methods¶
parseLine¶
| Spice | |
|---|---|
Parses a single CSV record into its fields. Newlines inside the input are preserved as part of the field they appear in.
Parameters
| Name | Type | Description |
|---|---|---|
input |
const String& |
Single CSV record (without trailing line terminator) |
Returns: Vector<String> — Parsed fields
parse¶
| Spice | |
|---|---|
Parses a whole CSV document into rows, where each row is a vector of fields.
An optional trailing line terminator is not treated as an additional empty record. Empty input yields an empty result.
Parameters
| Name | Type | Description |
|---|---|---|
input |
const String& |
Full CSV document |
Returns: Vector<Vector<String>> — Parsed rows