Bodu.Text.Delimited.Reader Namespace
- Package
-
Bodu.Text.Delimited 1.0.0
Purpose
Bodu.Text.Delimited.Reader is the lowest tier of Bodu.Text.Delimited: a forward-only, allocation-light token reader over UTF-8 delimited text (RFC 4180 CSV, TSV, and other single-character dialects). The DelimitedSerializer, the mutable DelimitedNode DOM, and the read-only DelimitedDocument DOM are all built over it, and its options struct is the single place the dialect and strictness policies are declared.
Key types
- Utf8DelimitedReader - the
ref structcursor:Read,TokenType(a DelimitedTokenType),ValueSpan/GetString,Headers,LineNumber, andBytesConsumed. - DelimitedReaderOptions -
Delimiter,Quote,NoHeader,TrimFields,AllowComments/CommentChar, and the policies DelimitedFieldCountBehavior, DelimitedMalformedRecordBehavior, and DelimitedDuplicateHeaderBehavior.
Example
using Bodu.Text.Delimited;
using Bodu.Text.Delimited.Reader;
var reader = new Utf8DelimitedReader("symbol,qty\nAAPL,10\n"u8);
while (reader.Read())
{
if (reader.TokenType == DelimitedTokenType.PropertyName)
Console.Write($"{reader.GetString()}=");
else if (reader.TokenType == DelimitedTokenType.String)
Console.WriteLine(reader.GetString());
}
Notes
- Header-shaped tokens. With a header row (the default) each record is an object of
PropertyName/Stringpairs keyed by the header; withNoHeadereach record is a positional array ofStringtokens. - String-only wire. Every field surfaces as a
Stringtoken; numeric or date conversion belongs to the serializer or the caller. - Malformed input throws DelimitedFormatException unless the relevant behavior policy relaxes it.
- See also: the line-formats introduction and the delimited guide.
Structs
- DelimitedReaderOptions
Provides configuration for a Utf8DelimitedReader, controlling the delimiter, quoting, header handling, and the field-count and duplicate-header policies.
- Utf8DelimitedReader
Provides a high-performance, forward-only reader for delimited (RFC 4180 CSV/TSV) bytes. The reader is a
ref struct, so it lives on the stack and cannot be boxed or captured.