Class CsvWriter
- Namespace
- FlameCsv
- Assembly
- FlameCsv.Core.dll
Provides static methods for writing CSV data.
public static class CsvWriter
- Inheritance
-
objectCsvWriter
Methods
Create(PipeWriter, CsvOptions<byte>?)
After use, the writer should be disposed, or completed with Complete(Exception?) or CompleteAsync(Exception?, CancellationToken).
public static CsvWriter<byte> Create(PipeWriter pipeWriter, CsvOptions<byte>? options = null)
Parameters
pipeWriterPipeWriterPipe to write the CSV to
optionsCsvOptions<byte>Options instance. If null, Default is used
Returns
Remarks
Writing to a pipe does not support synchronous flushing.
Create(Stream, CsvOptions<byte>?, in CsvIOOptions)
After use, the writer should be disposed, or completed with Complete(Exception?) or CompleteAsync(Exception?, CancellationToken).
public static CsvWriter<byte> Create(Stream stream, CsvOptions<byte>? options = null, in CsvIOOptions ioOptions = default)
Parameters
streamStreamStream to write the CSV to
optionsCsvOptions<byte>Options instance. If null, Default is used
ioOptionsCsvIOOptionsOptions to configure the buffer size whether to dispose the text writer
Returns
Create(TextWriter, CsvOptions<char>?, in CsvIOOptions)
Returns a writer instance that can be used to write custom fields, multiple different types,
or multiple CSV documents into the same output.
After use, the writer should be disposed, or completed with Complete(Exception?) or
CompleteAsync(Exception?, CancellationToken).
public static CsvWriter<char> Create(TextWriter textWriter, CsvOptions<char>? options = null, in CsvIOOptions ioOptions = default)
Parameters
textWriterTextWriterWriter to write the CSV to
optionsCsvOptions<char>Options instance. If null, Default is used
ioOptionsCsvIOOptionsOptions to configure the buffer size whether to dispose the text writer
Returns
WriteAsync<TValue>(PipeWriter, IAsyncEnumerable<TValue>, CsvTypeMap<byte, TValue>, CsvOptions<byte>?, CancellationToken)
Asynchronously writes the values as CSV records to the PipeWriter using the type map.
public static Task WriteAsync<TValue>(PipeWriter pipe, IAsyncEnumerable<TValue> values, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null, CancellationToken cancellationToken = default)
Parameters
pipePipeWriterPipe to write the CSV to
valuesIAsyncEnumerable<TValue>Values to write
typeMapCsvTypeMap<byte, TValue>Type map used to bind the CSV data
optionsCsvOptions<byte>Options to use, Default used by default
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(PipeWriter, IAsyncEnumerable<TValue>, CsvOptions<byte>?, CancellationToken)
Asynchronously writes the values as CSV records to the PipeWriter using TypeBinder.
[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 Task WriteAsync<TValue>(PipeWriter pipe, IAsyncEnumerable<TValue> values, CsvOptions<byte>? options = null, CancellationToken cancellationToken = default)
Parameters
pipePipeWriterPipe to write the CSV to
valuesIAsyncEnumerable<TValue>Values to write
optionsCsvOptions<byte>Options to use, Default used by default
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(PipeWriter, IEnumerable<TValue>, CsvTypeMap<byte, TValue>, CsvOptions<byte>?, CancellationToken)
Asynchronously writes the values as CSV records to the PipeWriter using the type map.
public static Task WriteAsync<TValue>(PipeWriter pipe, IEnumerable<TValue> values, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null, CancellationToken cancellationToken = default)
Parameters
pipePipeWriterPipe to write the CSV to
valuesIEnumerable<TValue>Values to write
typeMapCsvTypeMap<byte, TValue>Type map used to bind the CSV data
optionsCsvOptions<byte>Options to use, Default used by default
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(PipeWriter, IEnumerable<TValue>, CsvOptions<byte>?, CancellationToken)
Asynchronously writes the values as CSV records to the PipeWriter using TypeBinder.
[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 Task WriteAsync<TValue>(PipeWriter pipe, IEnumerable<TValue> values, CsvOptions<byte>? options = null, CancellationToken cancellationToken = default)
Parameters
pipePipeWriterPipe to write the CSV to
valuesIEnumerable<TValue>Values to write
optionsCsvOptions<byte>Options to use, Default used by default
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(Stream, IAsyncEnumerable<TValue>, CsvTypeMap<byte, TValue>, CsvOptions<byte>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to the Stream using the type map.
public static Task WriteAsync<TValue>(Stream stream, IAsyncEnumerable<TValue> values, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
streamStreamStream to write the CSV to
valuesIAsyncEnumerable<TValue>Values to write
typeMapCsvTypeMap<byte, TValue>Type map used to bind the CSV data
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(Stream, IAsyncEnumerable<TValue>, CsvOptions<byte>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to the Stream using TypeBinder.
[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 Task WriteAsync<TValue>(Stream stream, IAsyncEnumerable<TValue> values, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
streamStreamStream to write the CSV to
valuesIAsyncEnumerable<TValue>Values to write
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(Stream, IEnumerable<TValue>, CsvTypeMap<byte, TValue>, CsvOptions<byte>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to the Stream using the type map.
public static Task WriteAsync<TValue>(Stream stream, IEnumerable<TValue> values, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
streamStreamStream to write the CSV to
valuesIEnumerable<TValue>Values to write
typeMapCsvTypeMap<byte, TValue>Type map used to bind the CSV data
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(Stream, IEnumerable<TValue>, CsvOptions<byte>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to the Stream using TypeBinder.
[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 Task WriteAsync<TValue>(Stream stream, IEnumerable<TValue> values, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
streamStreamStream to write the CSV to
valuesIEnumerable<TValue>Values to write
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(TextWriter, IAsyncEnumerable<TValue>, CsvTypeMap<char, TValue>, CsvOptions<char>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to the TextWriter using the type map.
public static Task WriteAsync<TValue>(TextWriter textWriter, IAsyncEnumerable<TValue> values, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
textWriterTextWriterWriter to write the CSV to
valuesIAsyncEnumerable<TValue>Values to write
typeMapCsvTypeMap<char, TValue>Type map used to bind the CSV data
optionsCsvOptions<char>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(TextWriter, IAsyncEnumerable<TValue>, CsvOptions<char>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to the TextWriter using TypeBinder.
[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 Task WriteAsync<TValue>(TextWriter textWriter, IAsyncEnumerable<TValue> values, CsvOptions<char>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
textWriterTextWriterWriter to write the CSV to
valuesIAsyncEnumerable<TValue>Values to write
optionsCsvOptions<char>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(TextWriter, IEnumerable<TValue>, CsvTypeMap<char, TValue>, CsvOptions<char>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to the TextWriter using the type map.
public static Task WriteAsync<TValue>(TextWriter textWriter, IEnumerable<TValue> values, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
textWriterTextWriterWriter to write the CSV to
valuesIEnumerable<TValue>Values to write
typeMapCsvTypeMap<char, TValue>Type map used to bind the CSV data
optionsCsvOptions<char>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteAsync<TValue>(TextWriter, IEnumerable<TValue>, CsvOptions<char>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to the TextWriter using TypeBinder.
[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 Task WriteAsync<TValue>(TextWriter textWriter, IEnumerable<TValue> values, CsvOptions<char>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
textWriterTextWriterWriter to write the CSV to
valuesIEnumerable<TValue>Values to write
optionsCsvOptions<char>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFileAsync<TValue>(string, IAsyncEnumerable<TValue>, CsvTypeMap<byte, TValue>, CsvOptions<byte>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to a file using the type map.
public static Task WriteToFileAsync<TValue>(string path, IAsyncEnumerable<TValue> values, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIAsyncEnumerable<TValue>Values to write
typeMapCsvTypeMap<byte, TValue>Type map used to bind the CSV data
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFileAsync<TValue>(string, IAsyncEnumerable<TValue>, CsvTypeMap<char, TValue>, CsvOptions<char>?, Encoding?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to a file using the type map.
public static Task WriteToFileAsync<TValue>(string path, IAsyncEnumerable<TValue> values, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null, Encoding? encoding = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIAsyncEnumerable<TValue>Values to write
typeMapCsvTypeMap<char, TValue>Type map used to bind the CSV data
optionsCsvOptions<char>Options to use, Default used by default
encodingEncodingEncoding to pass to the inner StreamWriter
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFileAsync<TValue>(string, IAsyncEnumerable<TValue>, CsvOptions<byte>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to a file using TypeBinder.
[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 Task WriteToFileAsync<TValue>(string path, IAsyncEnumerable<TValue> values, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIAsyncEnumerable<TValue>Values to write
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFileAsync<TValue>(string, IAsyncEnumerable<TValue>, CsvOptions<char>?, Encoding?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to a file using TypeBinder.
[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 Task WriteToFileAsync<TValue>(string path, IAsyncEnumerable<TValue> values, CsvOptions<char>? options = null, Encoding? encoding = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIAsyncEnumerable<TValue>Values to write
optionsCsvOptions<char>Options to use, Default used by default
encodingEncodingEncoding to pass to the inner StreamWriter
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFileAsync<TValue>(string, IEnumerable<TValue>, CsvTypeMap<byte, TValue>, CsvOptions<byte>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to a file using the type map.
public static Task WriteToFileAsync<TValue>(string path, IEnumerable<TValue> values, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIEnumerable<TValue>Values to write
typeMapCsvTypeMap<byte, TValue>Type map used to bind the CSV data
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFileAsync<TValue>(string, IEnumerable<TValue>, CsvTypeMap<char, TValue>, CsvOptions<char>?, Encoding?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to a file using the type map.
public static Task WriteToFileAsync<TValue>(string path, IEnumerable<TValue> values, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null, Encoding? encoding = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIEnumerable<TValue>Values to write
typeMapCsvTypeMap<char, TValue>Type map used to bind the CSV data
optionsCsvOptions<char>Options to use, Default used by default
encodingEncodingEncoding to pass to the inner StreamWriter
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFileAsync<TValue>(string, IEnumerable<TValue>, CsvOptions<byte>?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to a file using TypeBinder.
[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 Task WriteToFileAsync<TValue>(string path, IEnumerable<TValue> values, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIEnumerable<TValue>Values to write
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFileAsync<TValue>(string, IEnumerable<TValue>, CsvOptions<char>?, Encoding?, CsvIOOptions, CancellationToken)
Asynchronously writes the values as CSV records to a file using TypeBinder.
[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 Task WriteToFileAsync<TValue>(string path, IEnumerable<TValue> values, CsvOptions<char>? options = null, Encoding? encoding = null, CsvIOOptions ioOptions = default, CancellationToken cancellationToken = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIEnumerable<TValue>Values to write
optionsCsvOptions<char>Options to use, Default used by default
encodingEncodingEncoding to pass to the inner StreamWriter
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
cancellationTokenCancellationTokenToken to cancel the writing operation
Returns
- Task
Task representing the asynchronous writing operation
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFile<TValue>(string, IEnumerable<TValue>, CsvTypeMap<byte, TValue>, CsvOptions<byte>?, CsvIOOptions)
Writes the values as CSV records to a file using the type map.
public static void WriteToFile<TValue>(string path, IEnumerable<TValue> values, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIEnumerable<TValue>Values to write
typeMapCsvTypeMap<byte, TValue>Type map used to bind the CSV data
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFile<TValue>(string, IEnumerable<TValue>, CsvTypeMap<char, TValue>, CsvOptions<char>?, Encoding?, CsvIOOptions)
Writes the values as CSV records to a file using the type map.
public static void WriteToFile<TValue>(string path, IEnumerable<TValue> values, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null, Encoding? encoding = null, CsvIOOptions ioOptions = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIEnumerable<TValue>Values to write
typeMapCsvTypeMap<char, TValue>Type map used to bind the CSV data
optionsCsvOptions<char>Options to use, Default used by default
encodingEncodingEncoding to pass to the inner StreamWriter
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFile<TValue>(string, IEnumerable<TValue>, CsvOptions<byte>?, CsvIOOptions)
Writes the values as CSV records to a file using TypeBinder.
[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 void WriteToFile<TValue>(string path, IEnumerable<TValue> values, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIEnumerable<TValue>Values to write
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToFile<TValue>(string, IEnumerable<TValue>, CsvOptions<char>?, Encoding?, CsvIOOptions)
Writes the values as CSV records to a file using TypeBinder.
[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 void WriteToFile<TValue>(string path, IEnumerable<TValue> values, CsvOptions<char>? options = null, Encoding? encoding = null, CsvIOOptions ioOptions = default)
Parameters
pathstringPath of the destination file. Existing files are overwritten
valuesIEnumerable<TValue>Values to write
optionsCsvOptions<char>Options to use, Default used by default
encodingEncodingEncoding to pass to the inner StreamWriter
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToString<TValue>(IEnumerable<TValue>, CsvTypeMap<char, TValue>, CsvOptions<char>?, StringBuilder?)
Writes the values as CSV records to a string using the type map.
public static StringBuilder WriteToString<TValue>(IEnumerable<TValue> values, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null, StringBuilder? builder = null)
Parameters
valuesIEnumerable<TValue>Values to write
typeMapCsvTypeMap<char, TValue>Type map used to bind the CSV data
optionsCsvOptions<char>Options to use, Default used by default
builderStringBuilderOptional builder to write the CSV to.
Returns
- StringBuilder
StringBuilder containing the CSV (same instance as
builderif provided)
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
WriteToString<TValue>(IEnumerable<TValue>, CsvOptions<char>?, StringBuilder?)
Writes the values as CSV records to a string using TypeBinder.
[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 StringBuilder WriteToString<TValue>(IEnumerable<TValue> values, CsvOptions<char>? options = null, StringBuilder? builder = null)
Parameters
valuesIEnumerable<TValue>Values to write
optionsCsvOptions<char>Options to use, Default used by default
builderStringBuilderOptional builder to write the CSV to.
Returns
- StringBuilder
StringBuilder containing the CSV (same instance as
builderif provided)
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
Write<TValue>(Stream, IEnumerable<TValue>, CsvTypeMap<byte, TValue>, CsvOptions<byte>?, CsvIOOptions)
Writes the values as CSV records to the Stream using the type map.
public static void Write<TValue>(Stream stream, IEnumerable<TValue> values, CsvTypeMap<byte, TValue> typeMap, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default)
Parameters
streamStreamStream to write the CSV to
valuesIEnumerable<TValue>Values to write
typeMapCsvTypeMap<byte, TValue>Type map used to bind the CSV data
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
Write<TValue>(Stream, IEnumerable<TValue>, CsvOptions<byte>?, CsvIOOptions)
Writes the values as CSV records to the Stream using TypeBinder.
[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 void Write<TValue>(Stream stream, IEnumerable<TValue> values, CsvOptions<byte>? options = null, CsvIOOptions ioOptions = default)
Parameters
streamStreamStream to write the CSV to
valuesIEnumerable<TValue>Values to write
optionsCsvOptions<byte>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
Write<TValue>(TextWriter, IEnumerable<TValue>, CsvTypeMap<char, TValue>, CsvOptions<char>?, CsvIOOptions)
Writes the values as CSV records to the TextWriter using the type map.
public static void Write<TValue>(TextWriter textWriter, IEnumerable<TValue> values, CsvTypeMap<char, TValue> typeMap, CsvOptions<char>? options = null, CsvIOOptions ioOptions = default)
Parameters
textWriterTextWriterWriter to write the CSV to
valuesIEnumerable<TValue>Values to write
typeMapCsvTypeMap<char, TValue>Type map used to bind the CSV data
optionsCsvOptions<char>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.
Write<TValue>(TextWriter, IEnumerable<TValue>, CsvOptions<char>?, CsvIOOptions)
Writes the values as CSV records to the TextWriter using TypeBinder.
[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 void Write<TValue>(TextWriter textWriter, IEnumerable<TValue> values, CsvOptions<char>? options = null, CsvIOOptions ioOptions = default)
Parameters
textWriterTextWriterWriter to write the CSV to
valuesIEnumerable<TValue>Values to write
optionsCsvOptions<char>Options to use, Default used by default
ioOptionsCsvIOOptionsOptions to configure the buffer size and other IO related options
Type Parameters
TValue
Remarks
Data is written even if values empty,
either just the header or an empty line if HasHeader is false.