Namespace CsvHelper
Assembly CsvHelper.dll
Builds net10.0 netstandard2.1 netstandard2.0 net47 A field is DBNull (IsDBNull ) when it is one of the reader's CsvReaderOptions.NullValues ; an empty field is an empty string unless "" is one of them. The columns are those of the header, or, without a header, of the first record.
Constructors
public CsvDataReader (CsvReader reader , bool leaveOpen = false )Creates a data reader over reader, which it reads from its current position.
Parameters readerCsvReader The CSV reader. Its header is read now, or, without one, its first record.
leaveOpenbool Whether reader stays open when the data reader is closed. Exceptions
View source
Properties
public override int Depth { get ; }Always 0: CSV is not nested.
Property value
View source
public override int FieldCount { get ; }The number of columns: those of the header, or of the first record.
Property value
View source
public override bool HasRows { get ; }true while the data reader is open; whether records remain is only known by reading.
Property value
View source
public override bool IsClosed { get ; }Whether Close has been called.
Property value
View source
public override int RecordsAffected { get ; }Always -1: reading changes no records.
Property value
View source
Indexers
public override object this [int ordinal ] { get ; }Gets the value of column ordinal. See GetValue .
Parameters
ordinalint The 0-based index of the column. Property value
View source
public override object this [string name ] { get ; }Gets the value of the column called name. See GetValue .
Parameters
namestring The name of the column. Property value
View source
Methods
public override void Close ()Closes the data reader, and disposes the CSV reader unless it was created with leaveOpen.
View source
protected override void Dispose (bool disposing )Closes the data reader. See Close .
Parameters
View source
public override bool GetBoolean (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
public override byte GetByte (int ordinal )Parses the field as a byte , in the reader's format provider.
Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
public override long GetBytes (int ordinal , long dataOffset , byte []? buffer , int bufferOffset , int length )Copies the UTF-8 bytes of the field into buffer.
Parameters
ordinalint The 0-based index of the column.
dataOffsetlong The offset in the field to start copying from.
bufferbyte []?Receives the bytes, or null to get the length of the field.
bufferOffsetint The offset in buffer to copy to.
lengthint The largest number of bytes to copy. Returns
long The number of bytes copied, or the length of the field when buffer is null.
View source
public override char GetChar (int ordinal )Gets the first character of the field.
Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
public override long GetChars (int ordinal , long dataOffset , char []? buffer , int bufferOffset , int length )Copies the characters of the field into buffer.
Parameters
ordinalint The 0-based index of the column.
dataOffsetlong The offset in the field to start copying from.
bufferchar []?Receives the characters, or null to get the length of the field.
bufferOffsetint The offset in buffer to copy to.
lengthint The largest number of characters to copy. Returns
long The number of characters copied, or the length of the field when buffer is null.
View source
public override string GetDataTypeName (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
View source
public override DateTime GetDateTime (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
public override decimal GetDecimal (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
public override double GetDouble (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
Returns
View source
public override Type GetFieldType (int ordinal )Always string : CSV fields are text.
Parameters
ordinalint The 0-based index of the column. Returns
View source
public override float GetFloat (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
public override Guid GetGuid (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
public override short GetInt16 (int ordinal )Parses the field as a short , in the reader's format provider.
Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
public override int GetInt32 (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
public override long GetInt64 (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
Exceptions
View source
public override string GetName (int ordinal )Gets the name of column ordinal.
Parameters
ordinalint The 0-based index of the column. Returns
string The header name, or Column and the 1-based number without a header.
Exceptions
View source
public override int GetOrdinal (string name )Parameters
namestring The name of the column. Returns
int The 0-based index of the column.
Exceptions
View source
Describes the columns for DataTable.Load and other consumers: their names, ordinals and type (string ), all of them nullable.
Returns
View source
public override string GetString (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
string The value of the field.
View source
public override object GetValue (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
View source
public override int GetValues (object [] values )Copies the values of the current record into values. See GetValue .
Parameters
valuesobject []Receives the values, up to its length. Returns
int The number of values copied.
Exceptions
View source
public override bool IsDBNull (int ordinal )Parameters
ordinalint The 0-based index of the column. Returns
bool true for a null value.
View source
public override bool NextResult ()Always false: a CSV file has one result set.
Returns
View source
public override bool Read ()Returns
bool Whether the data reader is positioned on a record.
Exceptions
View source