API reference
API reference
Every public type of the library, read from the net10.0, netstandard2.1, netstandard2.0, net47 builds. Members that only some builds have are marked, and where a member differs between builds, both versions are shown.
Classes
CsvAsyncQuery<T>
Class
A CSV query that runs asynchronously: await foreach over it, or the asynchronous versions of the LINQ operators that run a query (CsvAsyncQuery<T>.ToListAsync, CsvAsyncQuery<T>.CountAsync(CancellationToken), CsvAsyncQuery<T>.FirstAsync(CancellationToken) and the others), which read the CSV asynchronously.
CsvDataReader
Class
An IDataReader over a CsvReader, for APIs that read data readers: DataTable.Load, SqlBulkCopy.WriteToServer and the like.
CsvDynamicRecord
Class
A record read without a record type, by GetRecords<dynamic>(): its fields are members named after the header (record.Name), or Field1, Field2 and so on without a header.
CsvEnumExtensions
Static class · net10.0 only
The overloads of Parse<T>, TryParse<T> and ParseOrNull<T> for enums, whose types are not ISpanParsable<T>: reader.Parse<Status>(2) calls the method of this class.
CsvEnumerable
Static class
Writes the results of any query (of CSV, of a database through Entity Framework Core, or in memory) as CSV: records of CsvRecordAttribute types with their generated writers, dictionaries and dynamic records by their keys, and anything else, such as anonymous types, tuples and entities, by their public members of simple types.
CsvForeignQueryPlan
Class
A query of another LINQ provider that a CSV query runs, such as a table of Entity Framework Core.
CsvQuery<T>
Class
A LINQ query over CSV records: its source (CsvQueryable), and the operators applied to it.
CsvQueryPlan
Class
How a CSV query runs: for each CSV source it reads, what the reader does; what it asks other providers for; and the operators that LINQ to Objects runs on the records.
CsvQueryable
Static class
Creates LINQ queries over CSV records: the records of a file, a stream, text or bytes as CsvRecordAttribute types, or as CsvDynamicRecord rows for files without a record type.
CsvReader
Class
A forward-only CSV reader.
CsvRecordMapper
Static class
Finds the generated CsvRecordMapper<T> of a CsvRecordAttribute type.
CsvRecordMapper<T>
Class
Reads records of type T from the columns of one reader's header.
CsvRecordMember
Class
A member of a CsvRecordAttribute type that its generated mapper reads, as CsvRecordMapper.TryGetMembers describes it.
CsvRecordWriter
Static class
Finds the generated CsvRecordWriter<T> of a CsvRecordAttribute type.
CsvRecordWriter<T>
Class
Writes records of type T as fields of a CsvWriter, in the columns that a CsvRecordMapper<T> reads.
CsvSeparatorStream
Class
A read-only stream that lets CsvReader read files whose separator is longer than one character, such as ||, or is not ASCII: it puts one byte, CsvSeparatorStream.Replacement, in place of every separator.
CsvSourcePlan
Class
What the reader of one CSV source of a query does.
CsvTable<T>
Class
The records of a CSV file, to query (as a CsvQuery<T>) and to change: records can be added to the file, and records that match a condition removed or changed, which rewrites the file.
CsvWriter
Class
Writes CSV as UTF-8, RFC 4180 by default.
Records
CsvMalformedRecord
Record struct
Describes a malformed record passed to CsvReaderOptions.OnMalformedRecord.
CsvQueryOptions
Record
How a CSV query reads its source, and how much of the work it pushes into the reader and to other providers.
CsvReaderOptions
Record
Options for CsvReader.
CsvRecordError
Record struct
Describes a record that could not be mapped to its type, passed to CsvReaderOptions.OnRecordError.
CsvWriterOptions
Record
Options for CsvWriter.
Structs
Attributes
CsvBooleanValuesAttribute
Attribute
Reads a bool member of a CsvRecordAttribute type with the given true and false values, such as Ja and Nein, instead of those of Parse<bool> (CsvReader.Parse<T>(int)).
CsvColumnAttribute
Attribute
Chooses the column of a member or constructor parameter of a CsvRecordAttribute type.
CsvConstantAttribute
Attribute
Gives a member of a CsvRecordAttribute type a fixed value instead of reading a column: every record read gets CsvConstantAttribute.Value, and the record writer writes it in the member's column, whatever the member holds.
CsvConstructorAttribute
Attribute
Chooses the constructor that creates the records of a CsvRecordAttribute type.
CsvConverterAttribute
Attribute
On a member of a CsvRecordAttribute type, reads the member with an ICsvConverter<T>.
CsvCultureAttribute
Attribute
Reads a member of a CsvRecordAttribute type with the given culture instead of the reader's CsvReaderOptions.FormatProvider, for files whose columns use different number or date formats.
CsvDefaultAttribute
Attribute
The value that an empty field gives a member of a CsvRecordAttribute type, instead of a FormatException for a number, null for a Nullable<T> or "" for a string.
CsvEnumNameAttribute
Attribute
Gives a member of an enum other names that the members of CsvRecordAttribute types and Parse<T> of the reader read as it, such as "on hold" for OnHold.
CsvFormatAttribute
Attribute
Reads a member of a CsvRecordAttribute type with an exact format, such as "yyyyMMdd", instead of the formats that the format provider accepts.
CsvIgnoreAttribute
Attribute
Excludes a property or field of a CsvRecordAttribute type from reading.
CsvIgnoreBaseAttribute
Attribute
Reads and writes only the members that a CsvRecordAttribute class declares itself, not those of its base classes.
CsvNullValuesAttribute
Attribute
Reads the given values of a field as null, for a member of a CsvRecordAttribute type whose type is a reference type or a Nullable<T>, such as NULL or \N in database exports.
CsvOptionsAttribute
Attribute
Keeps the dialect of a CsvRecordAttribute type's files next to the type: the settings that CsvReaderOptions.For and CsvWriterOptions.For put in the options they return, such as [CsvOptions(Separator = ';', HasHeader = false)].
CsvRecordAttribute
Attribute
Marks a partial class, struct or record that CsvReader.GetRecords can read.
CsvRecordMapAttribute
Attribute
Maps a type that you cannot annotate, such as a type of another library or generated code: on a partial class, makes the source generator write the mapper and record writer of CsvRecordMapAttribute.RecordType as if it were a CsvRecordAttribute type, with the attributes that the members of this class carry.
CsvRecordProjectionsAttribute
Attribute
Makes the source generator write projections for the CsvRecordAttribute types of the assembly: mappers that read only some members (CsvRecordMapper.CreateProjection), so that the columns of the others are neither looked up nor parsed.
CsvValidateAttribute
Attribute
Checks the value of a member of a CsvRecordAttribute type with a static method of the type, such as [CsvValidate(nameof(IsValidAge))]: a value that the method rejects makes the record fail with a CsvValidationException, which the record methods of CsvReader report in a CsvFormatException that names the record, the field and the member.
Exceptions
CsvFormatException
Exception
Thrown when CSV input is malformed and the reader was configured to reject it, and when a record cannot be read as its CsvRecordAttribute type (the cause is then the Exception.InnerException).
CsvValidationException
Exception
Thrown when the method of a CsvValidateAttribute rejects the value of a member.
Enums
CsvFieldCountHandling
Enum
What the reader does when a record's field count differs from the header or first record.
CsvInjection
Enum
What CsvWriter does with a text field that starts with one of CsvWriterOptions.InjectionCharacters, which a spreadsheet such as Excel would run as a formula when it opens the file (CSV injection).
CsvMalformedDataHandling
Enum
What the reader does when the input breaks the quoting rules.
CsvMalformedReason
Enum
Why a record was reported as malformed.
CsvMissingFieldHandling
Enum
What happens when a field past the end of the current record is requested.
CsvMode
Enum
How fields are delimited and escaped, for CsvReader and CsvWriter.
CsvQuoting
Enum
When CsvWriter encloses fields in quotes.
CsvRecordMemberKind
Enum
How a CsvRecordMember gets its value.
Delegates
CsvShouldQuote
Delegate
Decides whether CsvWriter quotes a field in CsvMode.Rfc4180 mode (CsvWriterOptions.ShouldQuote).
CsvShouldSkipRecord
Delegate
Decides whether the reader skips a record (CsvReaderOptions.ShouldSkipRecord), such as a total or a section title in the middle of the data.
CsvTryParser<T>
Delegate
Tries to parse a field value, for the TryParse and ParseOrNull overloads that take a parser.