Bodu.Text.Delimited.Nodes Namespace
- Package
-
Bodu.Text.Delimited 1.0.0
Purpose
Bodu.Text.Delimited.Nodes is the mutable document object model of Bodu.Text.Delimited: parse a delimited document into an editable array of records, add or change fields, and write it back through the Utf8DelimitedWriter. Records are header-keyed objects (or positional arrays under NoHeader) and every field is a string. For read-only inspection use the sibling Bodu.Text.Delimited.Document tier; for typed records use the DelimitedSerializer.
Key types
- DelimitedNode - abstract base:
Parse(returning the record array),AsArray/AsObject/AsValue,ValueKind,DeepClone,WriteTo, andToUtf8Bytes. - DelimitedArray - the record set (and a positional record):
Add,RemoveAt,Count, and an integer indexer. - DelimitedObject - a header-keyed record:
Keys,ContainsKey/TryGetValue/Remove, and a string indexer that adds or replaces. - DelimitedValue - a single field with a settable
Value.
Example
using Bodu.Text.Delimited.Nodes;
DelimitedArray records = DelimitedNode.Parse("symbol,qty\nAAPL,10\n"u8);
records[0].AsObject()["qty"].AsValue().Value = "15";
var extra = new DelimitedObject();
extra["symbol"] = new DelimitedValue("MSFT");
extra["qty"] = new DelimitedValue("5");
records.Add(extra);
byte[] csv = records.ToUtf8Bytes();
Notes
- Trivia-free. Comments and original quoting are not preserved; the writer re-quotes minimally on output.
- Consistent shape. Every record in the array should share the first record's keys - the header is derived from the first object when writing.
- See also: the line-formats introduction and the delimited guide.
Classes
- DelimitedArray
Represents an array node in a mutable delimited document tree: the document of records, or a positional (headerless) record of string fields.
- DelimitedNode
Represents a node in a mutable delimited (CSV/TSV) document tree. A delimited document is an array of records, so the tree has three concrete shapes: a DelimitedArray (the document, or a positional record), a DelimitedObject (a header-keyed record), and a DelimitedValue string field.
- DelimitedObject
Represents a header-keyed record object in a mutable delimited document tree: an insertion-ordered map of column names to DelimitedNode field values.
- DelimitedValue
Represents a string-valued field in a mutable delimited document tree.