Profiles and builders

A reader profile combines independent settings. Use a format-specific builder so its syntax defaults and supported options are applied before reading.

Part Responsibility Guide
Dialect/format Record boundaries, quoting, labels Format guides
Schema Field names, types, cultures and formats Schemas
Resource Encoding, compression, replacement sequences Input initialization, compression, nulls
Filters Conditions applied to exposed columns before materialization Reader filtering
Runtime parsers Conversion shared by runtime type Custom parsers
Parser options Buffering and supported format options Tuning
using System.Text;
using PocketCsvReader.Configuration;

var csv = new CsvReaderBuilder()
    .WithDialect(d => d.WithHeader().WithLineTerminator("\n"))
    .WithSchema(s => s.Named().WithField<int>("Id").WithField<string>("Name"))
    .WithResource(r => r.WithEncoding("utf-8"))
    .Build();
using var stream = new MemoryStream(Encoding.UTF8.GetBytes("Id,Name\n7,Ada\n"));
foreach (var row in csv.ToDictionaries(stream))
    Console.WriteLine($"{row["Id"]}: {row["Name"]}");
7: Ada

Builder overloads accept configuration callbacks and descriptors. CSV uses WithDialect; other builders expose their own format settings. Configure profiles before constructing/initializing a reader. Supplying a shared options record does not imply every format supports every option.

Generated row-number column

WithRowNumber() prepends an int column named rowNumber; WithRowNumber("recordId") selects another name, and WithoutRowNumber() disables it. Direct profiles use RowNumber = new RowNumberOptions() or null. See batch reading and row numbering for numbering, headers, collisions, and object mapping.

Class CsvReaderBuilder

The current method is WithDialect(...), followed by Build(). Dialect methods and defaults are documented in CSV and TSV.

Class DialectDescriptorBuilder

Use this builder to produce a DialectDescriptor, or pass its callback directly to WithDialect. See the dialect reference and configuration validation.


Use inverted indexes
Schemas, formats, and cultures