Class CsvReader
- Namespace
- FlameCsv
- Assembly
- FlameCsv.Core.dll
Provides static methods for reading CSV data.
public static class CsvReader
- Inheritance
-
CsvReader
Methods
Enumerate(in ReadOnlySequence<byte>, CsvOptions<byte>?)
Reads CSV records from the data.
public static CsvRecordEnumerable<byte> Enumerate(in ReadOnlySequence<byte> csv, CsvOptions<byte>? options = null)
Parameters
csv
ReadOnlySequence<byte>CSV data
options
CsvOptions<byte>Options to use, Default used by default
Returns
Remarks
If the options-instance is configured to have a header, the first returned record will be the one after that.
The returned CsvValueRecord<T> instances are intended to be used only within aforeach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
Enumerate(in ReadOnlySequence<char>, CsvOptions<char>?)
Reads CSV records from the data.
public static CsvRecordEnumerable<char> Enumerate(in ReadOnlySequence<char> csv, CsvOptions<char>? options = null)
Parameters
csv
ReadOnlySequence<char>CSV data
options
CsvOptions<char>Options to use, Default used by default
Returns
Remarks
If the options-instance is configured to have a header, the first returned record will be the one after that.
The returned CsvValueRecord<T> instances are intended to be used only within aforeach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
Enumerate(Stream, CsvOptions<byte>?, CsvReaderOptions)
Reads CSV records from the Stream.
public static CsvRecordEnumerable<byte> Enumerate(Stream stream, CsvOptions<byte>? options = null, CsvReaderOptions readerOptions = default)
Parameters
stream
StreamStream to read the records from
options
CsvOptions<byte>Options to use, Default used by default
readerOptions
CsvReaderOptionsOptions to configure the inner reader
Returns
Remarks
foreach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
Enumerate(Stream, CsvOptions<char>?, Encoding?, CsvReaderOptions)
Reads CSV records from the stream by creating a StreamReader using the provided options.
public static CsvRecordEnumerable<char> Enumerate(Stream stream, CsvOptions<char>? options = null, Encoding? encoding = null, CsvReaderOptions readerOptions = default)
Parameters
stream
StreamStream to read the records from
options
CsvOptions<char>Options to use, Default used by default
encoding
EncodingEncoding to use for the inner StreamReader
readerOptions
CsvReaderOptionsOptions to configure the inner reader
Returns
Remarks
foreach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
Enumerate(TextReader, CsvOptions<char>?, CsvReaderOptions)
Reads CSV records from the TextReader.
public static CsvRecordEnumerable<char> Enumerate(TextReader textReader, CsvOptions<char>? options = null, CsvReaderOptions readerOptions = default)
Parameters
textReader
TextReaderText reader to read the records from
options
CsvOptions<char>Options to use, Default used by default
readerOptions
CsvReaderOptionsOptions to configure the inner reader
Returns
Remarks
foreach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
Enumerate(ReadOnlyMemory<byte>, CsvOptions<byte>?)
Reads CSV records from the data.
public static CsvRecordEnumerable<byte> Enumerate(ReadOnlyMemory<byte> csv, CsvOptions<byte>? options = null)
Parameters
csv
ReadOnlyMemory<byte>CSV data
options
CsvOptions<byte>Options to use, Default used by default
Returns
Remarks
If the options-instance is configured to have a header, the first returned record will be the one after that.
The returned CsvValueRecord<T> instances are intended to be used only within aforeach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
Enumerate(ReadOnlyMemory<char>, CsvOptions<char>?)
Reads CSV records from the data.
public static CsvRecordEnumerable<char> Enumerate(ReadOnlyMemory<char> csv, CsvOptions<char>? options = null)
Parameters
csv
ReadOnlyMemory<char>CSV data
options
CsvOptions<char>Options to use, Default used by default
Returns
Remarks
If the options-instance is configured to have a header, the first returned record will be the one after that.
The returned CsvValueRecord<T> instances are intended to be used only within aforeach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
Enumerate(string?, CsvOptions<char>?)
Reads CSV records from the data.
public static CsvRecordEnumerable<char> Enumerate(string? csv, CsvOptions<char>? options = null)
Parameters
csv
stringCSV data
options
CsvOptions<char>Options to use, Default used by default
Returns
Remarks
If the options-instance is configured to have a header, the first returned record will be the one after that.
The returned CsvValueRecord<T> instances are intended to be used only within aforeach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
EnumerateAsync(PipeReader, CsvOptions<byte>?)
Reads CSV records from the PipeReader.
public static IAsyncEnumerable<CsvValueRecord<byte>> EnumerateAsync(PipeReader pipeReader, CsvOptions<byte>? options = null)
Parameters
pipeReader
PipeReaderPipe to read the records from
options
CsvOptions<byte>Options to use, Default used by default
Returns
Remarks
foreach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
Enumerate<T>(in ReadOnlySequence<T>, CsvOptions<T>?)
Reads CSV records from the data.
[EditorBrowsable(EditorBrowsableState.Never)]
public static CsvRecordEnumerable<T> Enumerate<T>(in ReadOnlySequence<T> csv, CsvOptions<T>? options = null) where T : unmanaged, IBinaryInteger<T>
Parameters
csv
ReadOnlySequence<T>CSV data
options
CsvOptions<T>Options to use, Default used by default
Returns
Type Parameters
T
Remarks
If the options-instance is configured to have a header, the first returned record will be the one after that.
The returned CsvValueRecord<T> instances are intended to be used only within aforeach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
Enumerate<T>(ReadOnlyMemory<T>, CsvOptions<T>?)
Reads CSV records from the data.
[EditorBrowsable(EditorBrowsableState.Never)]
public static CsvRecordEnumerable<T> Enumerate<T>(ReadOnlyMemory<T> csv, CsvOptions<T>? options = null) where T : unmanaged, IBinaryInteger<T>
Parameters
csv
ReadOnlyMemory<T>CSV data
options
CsvOptions<T>Options to use, Default used by default
Returns
Type Parameters
T
Remarks
If the options-instance is configured to have a header, the first returned record will be the one after that.
The returned CsvValueRecord<T> instances are intended to be used only within aforeach
-loop.
The records are valid only until the next record is read, and accessing them at any point after that
(including using LINQ methods such as First()
) will result in a runtime error.
Convert the record to CsvRecord<T> to make a copy of the data if you need to preserve it.
Read<TValue>(in ReadOnlySequence<byte>, CsvTypeMap<byte, TValue>, CsvOptions<byte>)
Parses instances of TValue
from the CSV data using a precompiled type map.
public static CsvTypeMapEnumerable<byte, TValue> Read<TValue>(in ReadOnlySequence<byte> csv, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte> options)
Parameters
csv
ReadOnlySequence<byte>CSV data
typeMap
CsvTypeMap<byte, TValue>Precompiled type map
options
CsvOptions<byte>Options to use, Default used by default
Returns
- CsvTypeMapEnumerable<byte, TValue>
Type Parameters
TValue
Read<TValue>(in ReadOnlySequence<char>, CsvTypeMap<char, TValue>, CsvOptions<char>)
Parses instances of TValue
from the CSV data using a precompiled type map.
public static CsvTypeMapEnumerable<char, TValue> Read<TValue>(in ReadOnlySequence<char> csv, CsvTypeMap<char, TValue> typeMap, CsvOptions<char> options)
Parameters
csv
ReadOnlySequence<char>CSV data
typeMap
CsvTypeMap<char, TValue>Precompiled type map
options
CsvOptions<char>Options to use, Default used by default
Returns
- CsvTypeMapEnumerable<char, TValue>
Type Parameters
TValue
Read<TValue>(PipeReader, CsvTypeMap<byte, TValue>, CsvOptions<byte>?)
Parses instances of TValue
from the pipe using a precompiled type map.
public static ICsvValueAsyncEnumerable<byte, TValue> Read<TValue>(PipeReader reader, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null)
Parameters
reader
PipeReaderPipe to read the records from
typeMap
CsvTypeMap<byte, TValue>Precompiled type map
options
CsvOptions<byte>Options to use, Default used by default
Returns
- ICsvValueAsyncEnumerable<byte, TValue>
Type Parameters
TValue
Read<TValue>(PipeReader, CsvOptions<byte>?)
Parses instances of TValue
from the pipe using reflection.
[RequiresUnreferencedCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
[RequiresDynamicCode("This code path uses compiled expressions. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static ICsvValueAsyncEnumerable<byte, TValue> Read<TValue>(PipeReader reader, CsvOptions<byte>? options = null)
Parameters
reader
PipeReaderPipe to read the records from
options
CsvOptions<byte>Options to use, Default used by default
Returns
- ICsvValueAsyncEnumerable<byte, TValue>
Type Parameters
TValue
Read<TValue>(Stream, CsvTypeMap<byte, TValue>, CsvOptions<byte>?, CsvReaderOptions)
Parses instances of TValue
from the stream using a precompiled type map.
public static CsvTypeMapEnumerable<byte, TValue> Read<TValue>(Stream stream, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null, CsvReaderOptions readerOptions = default)
Parameters
stream
StreamStream to read the records from
typeMap
CsvTypeMap<byte, TValue>Precompiled type map
options
CsvOptions<byte>Options to use, Default used by default
readerOptions
CsvReaderOptionsOptions to configure the inner reader
Returns
- CsvTypeMapEnumerable<byte, TValue>
Type Parameters
TValue
Read<TValue>(Stream, CsvTypeMap<char, TValue>, CsvOptions<char>?, Encoding?, CsvReaderOptions)
Parses instances of TValue
from the stream using a precompiled type map.
public static CsvTypeMapEnumerable<char, TValue> Read<TValue>(Stream stream, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null, Encoding? encoding = null, CsvReaderOptions readerOptions = default)
Parameters
stream
StreamStream to read the records from
typeMap
CsvTypeMap<char, TValue>Precompiled type map
options
CsvOptions<char>Options to use, Default used by default
encoding
EncodingEncoding to initialize the StreamWriter with
readerOptions
CsvReaderOptionsOptions to configure the inner reader
Returns
- CsvTypeMapEnumerable<char, TValue>
Type Parameters
TValue
Read<TValue>(Stream, CsvOptions<byte>?, CsvReaderOptions)
Parses instances of TValue
from the stream using reflection.
[RequiresUnreferencedCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
[RequiresDynamicCode("This code path uses compiled expressions. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static CsvValueEnumerable<byte, TValue> Read<TValue>(Stream stream, CsvOptions<byte>? options = null, CsvReaderOptions readerOptions = default)
Parameters
stream
StreamStream to read the records from
options
CsvOptions<byte>Options to use, Default used by default
readerOptions
CsvReaderOptionsOptions to configure the inner reader
Returns
- CsvValueEnumerable<byte, TValue>
Type Parameters
TValue
Read<TValue>(Stream, Encoding?, CsvOptions<char>?, CsvReaderOptions)
Parses instances of TValue
from the stream using reflection.
[RequiresUnreferencedCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
[RequiresDynamicCode("This code path uses compiled expressions. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static CsvValueEnumerable<char, TValue> Read<TValue>(Stream stream, Encoding? encoding = null, CsvOptions<char>? options = null, CsvReaderOptions readerOptions = default)
Parameters
stream
StreamStream to read the records from
encoding
EncodingEncoding to initialize the StreamWriter with
options
CsvOptions<char>Options to use, Default used by default
readerOptions
CsvReaderOptionsOptions to configure the inner reader
Returns
- CsvValueEnumerable<char, TValue>
Type Parameters
TValue
Read<TValue>(TextReader, CsvTypeMap<char, TValue>, CsvOptions<char>?, CsvReaderOptions)
Parses instances of TValue
from the text reader using a precompiled type map.
public static CsvTypeMapEnumerable<char, TValue> Read<TValue>(TextReader textReader, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null, CsvReaderOptions readerOptions = default)
Parameters
textReader
TextReaderText reader to read the records from
typeMap
CsvTypeMap<char, TValue>Precompiled type map
options
CsvOptions<char>Options to use, Default used by default
readerOptions
CsvReaderOptionsOptions to configure the inner reader
Returns
- CsvTypeMapEnumerable<char, TValue>
Type Parameters
TValue
Read<TValue>(TextReader, CsvOptions<char>?, CsvReaderOptions)
Parses instances of TValue
from the stream using reflection.
[RequiresUnreferencedCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
[RequiresDynamicCode("This code path uses compiled expressions. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static CsvValueEnumerable<char, TValue> Read<TValue>(TextReader textReader, CsvOptions<char>? options = null, CsvReaderOptions readerOptions = default)
Parameters
textReader
TextReaderText reader to read the records from
options
CsvOptions<char>Options to use, Default used by default
readerOptions
CsvReaderOptionsOptions to configure the inner reader
Returns
- CsvValueEnumerable<char, TValue>
Type Parameters
TValue
Read<TValue>(ReadOnlyMemory<byte>, CsvTypeMap<byte, TValue>, CsvOptions<byte>?)
Parses instances of TValue
from the CSV data using a precompiled type map.
public static CsvTypeMapEnumerable<byte, TValue> Read<TValue>(ReadOnlyMemory<byte> csv, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null)
Parameters
csv
ReadOnlyMemory<byte>CSV data
typeMap
CsvTypeMap<byte, TValue>Precompiled type map
options
CsvOptions<byte>Options to use, Default used by default
Returns
- CsvTypeMapEnumerable<byte, TValue>
Type Parameters
TValue
Read<TValue>(ReadOnlyMemory<byte>, CsvOptions<byte>?)
Parses instances of TValue
from the CSV data using reflection.
[RequiresUnreferencedCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
[RequiresDynamicCode("This code path uses compiled expressions. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static CsvValueEnumerable<byte, TValue> Read<TValue>(ReadOnlyMemory<byte> csv, CsvOptions<byte>? options = null)
Parameters
csv
ReadOnlyMemory<byte>CSV data
options
CsvOptions<byte>Options to use, Default used by default
Returns
- CsvValueEnumerable<byte, TValue>
Type Parameters
TValue
Read<TValue>(ReadOnlyMemory<char>, CsvTypeMap<char, TValue>, CsvOptions<char>?)
Parses instances of TValue
from the CSV data using a precompiled type map.
public static CsvTypeMapEnumerable<char, TValue> Read<TValue>(ReadOnlyMemory<char> csv, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null)
Parameters
csv
ReadOnlyMemory<char>CSV data
typeMap
CsvTypeMap<char, TValue>Precompiled type map
options
CsvOptions<char>Options to use, Default used by default
Returns
- CsvTypeMapEnumerable<char, TValue>
Type Parameters
TValue
Read<TValue>(ReadOnlyMemory<char>, CsvOptions<char>?)
Parses instances of TValue
from the CSV data using reflection.
[RequiresUnreferencedCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
[RequiresDynamicCode("This code path uses compiled expressions. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static CsvValueEnumerable<char, TValue> Read<TValue>(ReadOnlyMemory<char> csv, CsvOptions<char>? options = null)
Parameters
csv
ReadOnlyMemory<char>CSV data
options
CsvOptions<char>Options to use, Default used by default
Returns
- CsvValueEnumerable<char, TValue>
Type Parameters
TValue
Read<TValue>(string?, CsvTypeMap<char, TValue>, CsvOptions<char>?)
Parses instances of TValue
from the CSV data using a precompiled type map.
public static CsvTypeMapEnumerable<char, TValue> Read<TValue>(string? csv, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null)
Parameters
csv
stringCSV data
typeMap
CsvTypeMap<char, TValue>Precompiled type map
options
CsvOptions<char>Options to use, Default used by default
Returns
- CsvTypeMapEnumerable<char, TValue>
Type Parameters
TValue
Read<TValue>(string?, CsvOptions<char>?)
Parses instances of TValue
from the CSV data using reflection.
[RequiresUnreferencedCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
[RequiresDynamicCode("This code path uses compiled expressions. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static CsvValueEnumerable<char, TValue> Read<TValue>(string? csv, CsvOptions<char>? options = null)
Parameters
csv
stringCSV data
options
CsvOptions<char>Options to use, Default used by default
Returns
- CsvValueEnumerable<char, TValue>
Type Parameters
TValue
Read<T, TValue>(in ReadOnlySequence<T>, CsvTypeMap<T, TValue>, CsvOptions<T>)
Parses instances of TValue
from the CSV data using a precompiled type map.
public static CsvTypeMapEnumerable<T, TValue> Read<T, TValue>(in ReadOnlySequence<T> csv, CsvTypeMap<T, TValue> typeMap, CsvOptions<T> options) where T : unmanaged, IBinaryInteger<T>
Parameters
csv
ReadOnlySequence<T>CSV data
typeMap
CsvTypeMap<T, TValue>Precompiled type map
options
CsvOptions<T>Options to use, Default used by default
Returns
- CsvTypeMapEnumerable<T, TValue>
Type Parameters
T
TValue
Read<T, TValue>(in ReadOnlySequence<T>, CsvOptions<T>?)
Parses instances of TValue
from the CSV data using reflection.
[RequiresUnreferencedCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
[RequiresDynamicCode("This code path uses compiled expressions. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static CsvValueEnumerable<T, TValue> Read<T, TValue>(in ReadOnlySequence<T> csv, CsvOptions<T>? options = null) where T : unmanaged, IBinaryInteger<T>
Parameters
csv
ReadOnlySequence<T>CSV data
options
CsvOptions<T>Options to use, Default used by default
Returns
- CsvValueEnumerable<T, TValue>
Type Parameters
T
TValue
Read<T, TValue>(ReadOnlyMemory<T>, CsvTypeMap<T, TValue>, CsvOptions<T>)
Parses instances of TValue
from the CSV data using a precompiled type map.
public static CsvTypeMapEnumerable<T, TValue> Read<T, TValue>(ReadOnlyMemory<T> csv, CsvTypeMap<T, TValue> typeMap, CsvOptions<T> options) where T : unmanaged, IBinaryInteger<T>
Parameters
csv
ReadOnlyMemory<T>CSV data
typeMap
CsvTypeMap<T, TValue>Precompiled type map
options
CsvOptions<T>Options to use, Default used by default
Returns
- CsvTypeMapEnumerable<T, TValue>
Type Parameters
T
TValue
Read<T, TValue>(ReadOnlyMemory<T>, CsvOptions<T>?)
Parses instances of TValue
from the CSV data using reflection.
[RequiresUnreferencedCode("This code path uses reflection. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
[RequiresDynamicCode("This code path uses compiled expressions. Use the overloads accepting source generated CsvTypeMap for AOT/trimming compatible code.")]
public static CsvValueEnumerable<T, TValue> Read<T, TValue>(ReadOnlyMemory<T> csv, CsvOptions<T>? options = null) where T : unmanaged, IBinaryInteger<T>
Parameters
csv
ReadOnlyMemory<T>CSV data
options
CsvOptions<T>Options to use, Default used by default
Returns
- CsvValueEnumerable<T, TValue>
Type Parameters
T
TValue