Class CsvWriter
- Namespace
- FlameCsv
- Assembly
- FlameCsv.Core.dll
Provides static methods for writing CSV data.
public static class CsvWriter
- Inheritance
-
CsvWriter
Fields
DefaultBufferSize
Default buffer size for writing CSV data.
public const int DefaultBufferSize = 4096
Field Value
Methods
Create(PipeWriter, CsvOptions<byte>?, bool)
After use, the writer should be disposed, or completed with Complete(Exception?) or CompleteAsync(Exception?, CancellationToken).
public static CsvAsyncWriter<byte> Create(PipeWriter pipeWriter, CsvOptions<byte>? options = null, bool autoFlush = false)
Parameters
pipeWriter
PipeWriterPipe to write the CSV to
options
CsvOptions<byte>Options instance. If null, Default is used
autoFlush
boolWhether to automatically flush after
Returns
- CsvAsyncWriter<byte>
Writer instance
Remarks
Writing to a pipe does not support synchronous flushing.
Create(Stream, CsvOptions<byte>?, bool)
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, bool autoFlush = false)
Parameters
stream
StreamStream to write the CSV to
options
CsvOptions<byte>Options instance. If null, Default is used
autoFlush
boolWhether to automatically flush after
Returns
Create(TextWriter, CsvOptions<char>?, bool)
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, bool autoFlush = false)
Parameters
textWriter
TextWriterWriter to write the CSV to
options
CsvOptions<char>Options instance. If null, Default is used
autoFlush
boolWhether to automatically flush after
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
pipe
PipeWriterPipe to write the CSV to
values
IAsyncEnumerable<TValue>Values to write
typeMap
CsvTypeMap<byte, TValue>Type map to use for writing
options
CsvOptions<byte>Options to use, Default used by default
cancellationToken
CancellationTokenToken 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
pipe
PipeWriterPipe to write the CSV to
values
IAsyncEnumerable<TValue>Values to write
options
CsvOptions<byte>Options to use, Default used by default
cancellationToken
CancellationTokenToken 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
pipe
PipeWriterPipe to write the CSV to
values
IEnumerable<TValue>Values to write
typeMap
CsvTypeMap<byte, TValue>Type map to use for writing
options
CsvOptions<byte>Options to use, Default used by default
cancellationToken
CancellationTokenToken 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
pipe
PipeWriterPipe to write the CSV to
values
IEnumerable<TValue>Values to write
options
CsvOptions<byte>Options to use, Default used by default
cancellationToken
CancellationTokenToken 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>?, int, bool, 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, int bufferSize = -1, bool leaveOpen = false, CancellationToken cancellationToken = default)
Parameters
stream
StreamStream to write the CSV to
values
IAsyncEnumerable<TValue>Values to write
typeMap
CsvTypeMap<byte, TValue>Type map to use for writing
options
CsvOptions<byte>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the stream open after writing
cancellationToken
CancellationTokenToken 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>?, int, bool, 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, int bufferSize = -1, bool leaveOpen = false, CancellationToken cancellationToken = default)
Parameters
stream
StreamStream to write the CSV to
values
IAsyncEnumerable<TValue>Values to write
options
CsvOptions<byte>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the stream open after writing
cancellationToken
CancellationTokenToken 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>?, int, bool, 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, int bufferSize = -1, bool leaveOpen = false, CancellationToken cancellationToken = default)
Parameters
stream
StreamStream to write the CSV to
values
IEnumerable<TValue>Values to write
typeMap
CsvTypeMap<byte, TValue>Type map to use for writing
options
CsvOptions<byte>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the stream open after writing
cancellationToken
CancellationTokenToken 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>?, int, bool, 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, int bufferSize = -1, bool leaveOpen = false, CancellationToken cancellationToken = default)
Parameters
stream
StreamStream to write the CSV to
values
IEnumerable<TValue>Values to write
options
CsvOptions<byte>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the stream open after writing
cancellationToken
CancellationTokenToken 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>?, int, bool, 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, int bufferSize = -1, bool leaveOpen = false, CancellationToken cancellationToken = default)
Parameters
textWriter
TextWriterWriter to write the CSV to
values
IAsyncEnumerable<TValue>Values to write
typeMap
CsvTypeMap<char, TValue>Type map to use for writing
options
CsvOptions<char>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the writer open after writing
cancellationToken
CancellationTokenToken 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>?, int, bool, 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, int bufferSize = -1, bool leaveOpen = false, CancellationToken cancellationToken = default)
Parameters
textWriter
TextWriterWriter to write the CSV to
values
IAsyncEnumerable<TValue>Values to write
options
CsvOptions<char>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the writer open after writing
cancellationToken
CancellationTokenToken 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>?, int, bool, 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, int bufferSize = -1, bool leaveOpen = false, CancellationToken cancellationToken = default)
Parameters
textWriter
TextWriterWriter to write the CSV to
values
IEnumerable<TValue>Values to write
typeMap
CsvTypeMap<char, TValue>Type map to use for writing
options
CsvOptions<char>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the writer open after writing
cancellationToken
CancellationTokenToken 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>?, int, bool, 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, int bufferSize = -1, bool leaveOpen = false, CancellationToken cancellationToken = default)
Parameters
textWriter
TextWriterWriter to write the CSV to
values
IEnumerable<TValue>Values to write
options
CsvOptions<char>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the writer open after writing
cancellationToken
CancellationTokenToken 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>?, 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, CancellationToken cancellationToken = default)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IAsyncEnumerable<TValue>Values to write
typeMap
CsvTypeMap<byte, TValue>Type map to use for writing
options
CsvOptions<byte>Options to use, Default used by default
cancellationToken
CancellationTokenToken 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?, int, 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, int bufferSize = -1, CancellationToken cancellationToken = default)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IAsyncEnumerable<TValue>Values to write
typeMap
CsvTypeMap<char, TValue>Type map to use for writing
options
CsvOptions<char>Options to use, Default used by default
encoding
EncodingEncoding to pass to the inner StreamWriter
bufferSize
intBuffer size to use for writing
cancellationToken
CancellationTokenToken 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>?, 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, CancellationToken cancellationToken = default)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IAsyncEnumerable<TValue>Values to write
options
CsvOptions<byte>Options to use, Default used by default
cancellationToken
CancellationTokenToken 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?, int, 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, int bufferSize = -1, CancellationToken cancellationToken = default)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IAsyncEnumerable<TValue>Values to write
options
CsvOptions<char>Options to use, Default used by default
encoding
EncodingEncoding to pass to the inner StreamWriter
bufferSize
intBuffer size to use for writing
cancellationToken
CancellationTokenToken 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>?, 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, CancellationToken cancellationToken = default)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IEnumerable<TValue>Values to write
typeMap
CsvTypeMap<byte, TValue>Type map to use for writing
options
CsvOptions<byte>Options to use, Default used by default
cancellationToken
CancellationTokenToken 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?, int, 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, int bufferSize = -1, CancellationToken cancellationToken = default)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IEnumerable<TValue>Values to write
typeMap
CsvTypeMap<char, TValue>Type map to use for writing
options
CsvOptions<char>Options to use, Default used by default
encoding
EncodingEncoding to pass to the inner StreamWriter
bufferSize
intBuffer size to use for writing
cancellationToken
CancellationTokenToken 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>?, 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, CancellationToken cancellationToken = default)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IEnumerable<TValue>Values to write
options
CsvOptions<byte>Options to use, Default used by default
cancellationToken
CancellationTokenToken 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?, int, 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, int bufferSize = -1, CancellationToken cancellationToken = default)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IEnumerable<TValue>Values to write
options
CsvOptions<char>Options to use, Default used by default
encoding
EncodingEncoding to pass to the inner StreamWriter
bufferSize
intBuffer size to use for writing
cancellationToken
CancellationTokenToken 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>?)
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)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IEnumerable<TValue>Values to write
typeMap
CsvTypeMap<byte, TValue>Type map to use for writing
options
CsvOptions<byte>Options to use, Default used by default
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?, int)
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, int bufferSize = -1)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IEnumerable<TValue>Values to write
typeMap
CsvTypeMap<char, TValue>Type map to use for writing
options
CsvOptions<char>Options to use, Default used by default
encoding
EncodingEncoding to pass to the inner StreamWriter
bufferSize
intBuffer size to use for writing
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>?)
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)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IEnumerable<TValue>Values to write
options
CsvOptions<byte>Options to use, Default used by default
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?, int)
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, int bufferSize = -1)
Parameters
path
stringPath of the destination file. Existing files are overwritten
values
IEnumerable<TValue>Values to write
options
CsvOptions<char>Options to use, Default used by default
encoding
EncodingEncoding to pass to the inner StreamWriter
bufferSize
intBuffer size to use for writing
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
values
IEnumerable<TValue>Values to write
typeMap
CsvTypeMap<char, TValue>Type map to use for writing
options
CsvOptions<char>Options to use, Default used by default
builder
StringBuilderOptional builder to write the CSV to.
Returns
- StringBuilder
StringBuilder containing the CSV (same instance as
builder
if 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
values
IEnumerable<TValue>Values to write
options
CsvOptions<char>Options to use, Default used by default
builder
StringBuilderOptional builder to write the CSV to.
Returns
- StringBuilder
StringBuilder containing the CSV (same instance as
builder
if 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>?, int, bool)
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, int bufferSize = -1, bool leaveOpen = false)
Parameters
stream
StreamStream to write the CSV to
values
IEnumerable<TValue>Values to write
typeMap
CsvTypeMap<byte, TValue>Type map to use for writing
options
CsvOptions<byte>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the stream open after writing
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>?, int, bool)
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, int bufferSize = -1, bool leaveOpen = false)
Parameters
stream
StreamStream to write the CSV to
values
IEnumerable<TValue>Values to write
options
CsvOptions<byte>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the stream open after writing
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>?, int, bool)
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, int bufferSize = -1, bool leaveOpen = false)
Parameters
textWriter
TextWriterWriter to write the CSV to
values
IEnumerable<TValue>Values to write
typeMap
CsvTypeMap<char, TValue>Type map to use for writing
options
CsvOptions<char>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the writer open after writing
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>?, int, bool)
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, int bufferSize = -1, bool leaveOpen = false)
Parameters
textWriter
TextWriterWriter to write the CSV to
values
IEnumerable<TValue>Values to write
options
CsvOptions<char>Options to use, Default used by default
bufferSize
intBuffer size to use for writing
leaveOpen
boolWhether to leave the writer open after writing
Type Parameters
TValue