CsvBadDataContext Class

Describes malformed data found by CsvReader or Utf8CsvReader, passed to CsvReaderOptions.BadDataHandler.

public sealed class CsvBadDataContext

Remarks

The context is only valid during the call to the handler: the handler must not call the methods of the reader.

Properties

NameDescription
ColumnIndexGets the 0-based index of the column that contains the malformed data, or null when the error is about the whole record.
ColumnNameGets the name of the column from the header row, or null when the column has no name or the header row is not read yet.
ExceptionGets the exception that the reader throws for this error in strict mode, or when the handler returns CsvBadDataAction.Throw.
KindGets the kind of malformed data.
LineNumberGets the 1-based line number where the record starts.
MessageGets the description of the error, without its location.
PositionGets the 0-based position, in characters or in bytes from the start of the data, where the record starts.
RowIndexGets the 0-based index of the record, not counting the header row, or null when the record is the header row.

Gets the 0-based index of the column that contains the malformed data, or null when the error is about the whole record.

public int? ColumnIndex { get; }

Property value

int?

Gets the name of the column from the header row, or null when the column has no name or the header row is not read yet.

public string? ColumnName { get; }

Property value

string?

Gets the exception that the reader throws for this error in strict mode, or when the handler returns CsvBadDataAction.Throw.

public CsvException Exception { get; }

Property value

CsvException

Gets the kind of malformed data.

public CsvBadDataKind Kind { get; }

Property value

CsvBadDataKind

Gets the 1-based line number where the record starts.

public long LineNumber { get; }

Property value

long

Gets the description of the error, without its location.

public string Message { get; }

Property value

string

Gets the 0-based position, in characters or in bytes from the start of the data, where the record starts.

public long Position { get; }

Property value

long

Gets the 0-based index of the record, not counting the header row, or null when the record is the header row.

public long? RowIndex { get; }

Property value

long?