Skip to main content

Search OfficeIMO

Enter a topic, API type, or PowerShell command.

Documentation Search all OfficeIMO/
Class

CsvReaderOptions

OfficeIMO.CSV

Namespace
OfficeIMO.CSV
Assembly
OfficeIMO.CSV
Source revision
e163ccb36643 with working tree changes
Modifiers
sealed

Options controlling CSV parsing and forward-only reader projection.

Inheritance

  • object
  • CsvReaderOptions

Usage

Explore 12 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 2

Accepted by parameters 10

Constructors

public CsvReaderOptions() #

Methods

public CsvReaderOptions Clone() #

Creates an options copy with mutable collections snapshotted for deferred reads.

Properties

public CsvSchema? Schema { get; set; } #

Gets or sets an explicit schema used for typed reader columns.

public bool InferSchema { get; set; } #

Gets or sets a value indicating whether schema should be inferred before creating reader columns.

public int SchemaSampleRows { get; set; } #

Gets or sets the maximum row count inspected when CsvReaderOptions.InferSchema is enabled.

public CsvDataReaderParallelOptions? ParallelProcessing { get; set; } #

Gets or sets bounded, ordered parallel processing for typed reader values. When omitted, the reader remains fully sequential.

public bool HasHeaderRow { get; set; } #

Gets or sets whether the first record in the file represents the header row. Default is true. Ignored when CsvReaderOptions.Header is provided; in that case the first record is treated as data.

public string[]? Header { get; set; } #

Gets or sets explicit header names to use for the CSV data. When provided, no input row is consumed as the header.

public int SkipInitialRecords { get; set; } #

Gets or sets the number of parsed records to skip before header discovery or data emission. Default is 0.

public bool SkipCommentRowsBeforeHeader { get; set; } #

Gets or sets whether comment rows are skipped while discovering the header. Default is true. Comment rows are identified by CsvReaderOptions.CommentCharacter.

public bool SkipCommentRows { get; set; } #

Gets or sets whether comment rows are skipped throughout the file. Default is false. Comment rows are identified by CsvReaderOptions.CommentCharacter.

public int MaxCommentContinuationLines { get; set; } #

Gets or sets the maximum number of physical continuation lines inspected for a quoted comment record. Once the limit is reached, buffered lines are replayed as ordinary input instead of being retained while searching for a closing quote. Defaults to CsvReaderOptions.DefaultMaxCommentContinuationLines.

public char CommentCharacter { get; set; } #

Gets or sets the character that identifies a comment row when it appears at the start of a record. Default is #.

public bool RecognizeW3CFieldsHeader { get; set; } #

Gets or sets whether W3C Extended Log File Format #Fields: rows are recognized as headers. Default is true.

public bool GenerateMissingHeaderNames { get; set; } #

Gets or sets whether blank header names are replaced with generated names such as H1. Default is true.

public CsvDuplicateHeaderBehavior DuplicateHeaderBehavior { get; set; } #

Gets or sets how duplicate header names are handled. Default renames duplicate headers to keep name-based row access unambiguous.

public string? NullValue { get; set; } #

Gets or sets a token that should be materialized as null when loading rows into a CsvDocument. Raw string streaming callbacks preserve the source text.

public string[]? DateTimeFormats { get; set; } #

Gets or sets additional date/time formats used by typed row conversion and schema validation.

public DataMappingErrorValuePolicy MappingErrorValuePolicy { get; set; } #

Gets or sets whether schema and row-mapping failures may include source values. Defaults to DataMappingErrorValuePolicy.Include for compatibility.

public CsvQuoteParsingMode QuoteParsingMode { get; set; } #

Gets or sets how malformed quoted fields are handled. Default is CsvQuoteParsingMode.Lenient to preserve common PowerShell-style import behavior.

public IReadOnlyDictionary<string, object?>? StaticColumns { get; set; } #

Gets or sets columns appended to every loaded row, useful for source file names, import timestamps, or batch metadata.

public CsvColumnCountMismatchPolicy ColumnCountMismatchPolicy { get; set; } #

Gets or sets how parsed records are handled when their field count differs from the header count. Default pads missing fields and ignores extras, matching common PowerShell CSV import behavior.

public char Delimiter { get; set; } #

Gets or sets the field delimiter character. Default is ,.

public string? DelimiterText { get; set; } #

Gets or sets the field delimiter text. Leave unset to use CsvReaderOptions.Delimiter. Single-character values keep the optimized character delimiter path; longer values enable flexible delimiter parsing.

public bool DetectDelimiter { get; set; } #

Gets or sets whether the delimiter should be detected from the first meaningful records. Detection is opt-in and leaves CsvReaderOptions.Delimiter unchanged when no candidate clearly fits.

public char[]? DelimiterCandidates { get; set; } #

Gets or sets delimiter candidates used when CsvReaderOptions.DetectDelimiter is enabled. Defaults to comma, semicolon, pipe, and tab.

public bool TrimWhitespace { get; set; } #

Gets or sets whether leading and trailing whitespace should be trimmed from unquoted fields. Default is false.

public CultureInfo Culture { get; set; } #

Gets or sets the culture used for type conversions when reading. Defaults to CultureInfo.InvariantCulture.

public bool AllowEmptyLines { get; set; } #

Gets or sets whether empty lines should be preserved. Default is false (empty lines are ignored).

public Encoding? Encoding { get; set; } #

Gets or sets the text encoding to use when reading from files. Defaults to UTF-8 if not provided.

public bool DetectEncodingFromByteOrderMarks { get; set; } #

Gets or sets whether an input BOM may select the decoding encoding. Default is true. When false, the configured encoding remains authoritative and its own preamble is accepted. Use an encoding with exception fallback to reject invalid encoded input. This applies to byte-based file and stream APIs; text inputs are already decoded.

public CsvCompressionType CompressionType { get; set; } #

Gets or sets compression used when reading from files. Default infers compression from the file extension.

public long? MaxDecompressedBytes { get; set; } #

Gets or sets an optional limit for decompressed bytes read from compressed CSV files. Defaults to 256 MiB. Set to null only for trusted inputs that intentionally exceed the limit.

public long MaxInputBytes { get; set; } #

Gets or sets the maximum number of bytes accepted by stream-based and uncompressed path-based load APIs. Defaults to 256 MiB so untrusted inputs cannot be buffered without bound.

public CancellationToken CancellationToken { get; set; } #

Gets or sets an optional cancellation token checked while reading records.

public int ProgressReportInterval { get; set; } #

Gets or sets how often CsvReaderOptions.ProgressCallback is called, in emitted records. Default is 0, which disables progress callbacks.

public Action<CsvProgress>? ProgressCallback { get; set; } #

Gets or sets an optional callback invoked as records are emitted.

public bool CollectParseErrors { get; set; } #

Gets or sets whether parse errors should be collected into CsvReaderOptions.ParseErrors.

public CsvParseErrorAction ParseErrorAction { get; set; } #

Gets or sets how parse errors are handled. Default throws immediately.

public int MaxParseErrors { get; set; } #

Gets or sets the maximum number of collected parse errors before parsing fails. Default is 100.

public IList<CsvParseError>? ParseErrors { get; set; } #

Gets or sets the collection receiving parse errors when CsvReaderOptions.CollectParseErrors is enabled.

public int? MaxFieldLength { get; set; } #

Gets or sets an optional maximum length for any parsed field.

public int? MaxQuotedFieldLength { get; set; } #

Gets or sets an optional maximum length for fields parsed from quoted records.

public bool NormalizeQuotes { get; set; } #

Gets or sets whether curly quote characters are normalized to straight quotes while reading.

public bool InternStrings { get; set; } #

Gets or sets whether repeated string values are reused through a per-read string cache.

Fields

public const long DefaultMaxInputBytes #

Default maximum complete stream input size (256 MiB).

Value: 268435456
public const int DefaultMaxCommentContinuationLines #

Default maximum physical lines inspected while deciding whether a quoted comment continues.

Value: 64