• MARS Website
  • Core API
  • SmartOpenHamburg API
  • Model Components API
  • Common API
Show / Hide Table of Contents
  • Mars.Common
    • GeoHash
    • GeoHashDecoder
    • GeohashDecodeResult
    • GeoHashEncoder
    • GeoHashPrecision
    • Hyperrectangle
    • InputHashHelper
    • PositionHelper
  • Mars.Common.Collections
    • BinaryArrayHeap<T>
    • DoubleBits
    • FibonacciHeap<T, TKey>
    • FibonacciHeapDoubleKey<T>
    • FibonacciHeapNode<T, TKey>
    • FibonacciHeapNodeDoubleKey<T>
    • HeapNode
    • IntervalSize
    • K2DTree<T>
    • K2dTreeNode<T>
    • KdTree
    • KdTree<T>
    • KdTreeBase<TNode>
    • KdTreeNode
    • KdTreeNode<T>
    • KdTreeNodeBase<TNode>
    • KdTreeNodeCollection<TNode>
    • KdTreeNodeList<T>
    • Key
    • Node<T>
    • NodeBase<T>
    • NodeDataContainer<T>
    • NodeDistance<TNode>
    • QuadTree<T>
    • Root<T>
    • TreeDataContainer<T>
  • Mars.Common.Collections.CritBit
    • ICritBitTree<TValue>
  • Mars.Common.Collections.Graph
    • EdgeData
    • GraphData
    • GraphSerializer
    • ISpatialGraph
    • KeyContainer
    • NodeData
    • SpatialGraph
    • SpatialGraphHelper
  • Mars.Common.Collections.Graph.Algorithms
    • AStar
    • CompressedPathDatabase
    • ContractionSearch
    • DepthLimitedTraversal
  • Mars.Common.Collections.Graph.Helper
    • INodeFinder
    • KdTreeNodeFinder
    • RunLengthEncoder
  • Mars.Common.Collections.KNNGraph
    • DefaultRandomGenerator
    • DistanceUtils
    • EventSources
    • EventSources.GraphBuildEventSource
    • EventSources.GraphSearchEventSource
    • IProgressReporter
    • IProvideRandomValues
    • KnnGraph<TItem, TDistance>
    • KnnGraph<TItem, TDistance>.KnnSearchResult
    • KnnGraph<TItem, TDistance>.Parameters
    • Node
    • ReverseComparer<T>
    • ReverseComparerExtensions
    • SelectionKind
    • TravelingCosts<TItem, TDistance>
  • Mars.Common.Compat
    • FormatDecoderAttribute
    • FormatEncoderAttribute
    • FormatHandlerAttribute
    • IntegerAttribute
    • NegativeIntegerAttribute
    • NonnegativeIntegerAttribute
    • NonpositiveIntegerAttribute
    • PositiveIntegerAttribute
  • Mars.Common.Data
    • DomainDataImporter
  • Mars.Common.Data.Providers
    • AscDataProvider
    • GeoJsonFeatureCollectionConverter
    • GeoJsonFeatureConverter
    • GeoJsonHelper
    • GeometryDataProvider
    • GraphMlProvider
    • HttpDataProvider
    • IDataProvider<TInput>
    • JsonFileDataProvider
    • JsonTextDataProvider
    • XmlFileDataProvider
    • XmlTextDataProvider
  • Mars.Common.Exceptions
    • DimensionMismatchException
    • ParseException
  • Mars.Common.IO
    • ExtensionMethods
    • FileClientUtils
    • FileKeys
    • HttpClientUtils
    • ObjectSerialize
    • Serializer
    • SerializerCompression
    • SparseFormat
    • SparseReader
    • SparseWriter
  • Mars.Common.IO.Attributes
    • SerializationBinderAttribute
    • SurrogateSelectorAttribute
  • Mars.Common.IO.Console
    • ChildProgressBar
    • IProgressBar
    • ProgressBar
    • ProgressBarBase
    • ProgressBarHeight
    • ProgressBarOptions
    • ProgressBarSimple
  • Mars.Common.IO.Csv
    • CsvAnalyzer
    • CsvReader
    • CsvReader.RecordEnumerator
    • CsvWriter
    • MissingFieldAction
    • ParseErrorAction
    • ValueTrimmingOptions
  • Mars.Common.IO.Events
    • ParseErrorEventArgs
  • Mars.Common.IO.Exceptions
    • MalformedCsvException
    • MissingFieldCsvException
  • Mars.Common.IO.Mapped
    • Context
    • DefaultArrayFactory
    • Extensions
    • IArrayFactory
    • ISerializableToStream
    • MappedAccessor<T>
    • MemoryMap
    • MemoryMap.CreateAccessorFunc<T>
    • MemoryMap.ReadFromDelegate<T>
    • MemoryMap.WriteToDelegate<T>
    • MemoryMapDelegates
    • MemoryMapDelegates.CreateAccessorFunc<T>
    • MemoryMapStream
  • Mars.Common.IO.Mapped.Accessors
    • MappedAccessorByte
    • MappedAccessorDouble
    • MappedAccessorInt16
    • MappedAccessorInt32
    • MappedAccessorInt64
    • MappedAccessorSingle
    • MappedAccessorUInt16
    • MappedAccessorUInt32
    • MappedAccessorUInt64
    • MappedAccessorVariable<T>
  • Mars.Common.IO.Mapped.Arrays
    • Array<T>
    • ArrayBase<T>
    • ArrayProfile
    • MappedArray<TMapped, T>
    • MappedArray<TMapped, T>.MapFrom
    • MappedArray<TMapped, T>.MapTo
    • MemoryArray<T>
    • VariableArray<T>
  • Mars.Common.IO.Mapped.Collections
    • MemoryBackedDictionary<TKey, TValue>
    • MemoryBackedList<T>
  • Mars.Common.IO.Mapped.Indexes
    • Index<T>
  • Mars.Common.IO.Mapped.Streams
    • CappedStream
  • Mars.Common.Socket
    • ByteOrder
    • CloseEventArgs
    • CloseStatusCode
    • CompressionMethod
    • ErrorEventArgs
    • Ext
    • MessageEventArgs
    • WebSocket
    • WebSocketException
    • WebSocketState
  • Mars.Common.Socket.Server
    • IWebSocketSession
    • WebHeaderCollection
    • WebSocketBehavior
    • WebSocketContext
    • WebSocketServer
    • WebSocketServiceHost
    • WebSocketServiceManager
    • WebSocketSessionManager
  • Mars.Numerics
    • Classes
    • Combinatorics
    • Constants
    • Distance
    • Elementwise
    • Jagged
    • MathematicsException
    • MathHelper
    • Matrix
    • MatrixOrder
    • MatrixType
    • Norm
    • Sort
    • Sorting
    • Sparse
    • Sparse<T>
    • Tools
    • Vector
    • VectorHelper
    • VectorType
  • Mars.Numerics.Comparers
    • ArrayComparer<T>
    • ComparerDirection
    • CustomComparer<T>
    • ElementComparer
    • ElementComparer<T>
    • GeneralComparer
    • StableComparer<T>
  • Mars.Numerics.Distances
    • Angular
    • Chebyshev
    • Cosine
    • Dirac<T>
    • Euclidean
    • Hamming
    • Hamming<T>
    • Haversine
    • Jaccard
    • Jaccard<T>
    • Kulczynski
    • Levenshtein
    • Levenshtein<T>
    • Manhattan
    • Matching
    • Minkowski
    • SquareEuclidean
    • Vincenty
    • Vincenty.Ellipsoid
  • Mars.Numerics.Distances.Base
    • IDistance<T>
    • IDistance<TFirst, TSecond>
    • IMetric<T>
    • ISimilarity<T, TU>
    • ISimilarity<T>
  • Mars.Numerics.Exceptions
    • DimensionMismatchException
    • NonPositiveDefiniteMatrixException
    • SingularMatrixException
  • Mars.Numerics.Formats
    • DefaultMatrixFormatProvider
    • IMatrixFormatProvider
    • MatrixFormatProviderBase
    • MatrixFormatter
    • OctaveMatrixFormatProvider
  • Mars.Numerics.Ranges
    • ByteRange
    • DoubleRange
    • FloatRange
    • IntRange
    • IRange<T>
  • Mars.Numerics.Statistics
    • ConstValueDistribution<T>
    • Distribution<T>
    • FastGaussianDistributionD
    • FastGaussianDistributionF
    • IDistribution
    • UniformDiscreteDistribution
    • UniformDistributionD
    • UniformDistributionF
  • Mars.Numerics.Statistics.Base
    • BinarySearch
    • DistributionBase
    • ISampleableDistribution<TObservations>
    • IUnivariateDistribution
    • IUnivariateDistribution<TObservation>
    • UnivariateDiscreteDistribution

Class CsvWriter

Writer for CSV data.
Inheritance
System.Object
CsvWriter
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Common.IO.Csv
Assembly: Mars.IO.dll
Syntax
public sealed class CsvWriter : IDisposable
Examples

The following example shows how to use CsvWriter to write a matrix in .csv format.

The following example shows how to use CsvWriter to write a jagged array in .csv format.

The following example shows how to use CsvWriter to write a DataTable in .csv format.

It is also possible to use CsvWriter to write matrices (or jagged arrays) containing objects with mixed types:

Constructors

| Improve this Doc View Source

CsvWriter(TextWriter, Char)

Initializes a new instance of the CsvWriter class.
Declaration
public CsvWriter(TextWriter writer, char delimiter = ',')
Parameters
Type Name Description
System.IO.TextWriter writer A TextWriter pointing to the CSV file.
System.Char delimiter The field delimiter character to separate values in the CSV file. If set to zero, will use the system's default text separator. Default is '\0' (zero).
| Improve this Doc View Source

CsvWriter(String, Char)

Initializes a new instance of the CsvWriter class.
Declaration
public CsvWriter(string path, char delimiter = ',')
Parameters
Type Name Description
System.String path The path to the file to be written.
System.Char delimiter The field delimiter character to separate values in the CSV file. If set to zero, will use the system's default text separator. Default is '\0' (zero).

Properties

| Improve this Doc View Source

Comment

Gets or sets the comment character indicating that a line is commented out.
Declaration
public char Comment { get; set; }
Property Value
Type Description
System.Char The comment character indicating that a line is commented out.
| Improve this Doc View Source

Delimiter

Gets or sets the delimiter character separating each field.
Declaration
public char Delimiter { get; set; }
Property Value
Type Description
System.Char The delimiter character separating each field.
| Improve this Doc View Source

Escape

Gets or sets the escape character letting insert quotation characters inside a quoted field.
Declaration
public char Escape { get; set; }
Property Value
Type Description
System.Char The escape character letting insert quotation characters inside a quoted field.
| Improve this Doc View Source

FormatProvider

Gets or sets the format provider to use when converting data-types to text representations. Default is to use CultureInfo.InvariantCulture.
Declaration
public IFormatProvider FormatProvider { get; set; }
Property Value
Type Description
System.IFormatProvider The format provider.
| Improve this Doc View Source

Quote

Gets or sets the quotation character wrapping every field.
Declaration
public char Quote { get; set; }
Property Value
Type Description
System.Char The quotation character wrapping every field.
| Improve this Doc View Source

Writer

Gets the writer.
Declaration
public TextWriter Writer { get; }
Property Value
Type Description
System.IO.TextWriter The writer.

Methods

| Improve this Doc View Source

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
| Improve this Doc View Source

Finalize()

Finalizes an instance of the CsvWriter class.
Declaration
protected void Finalize()
| Improve this Doc View Source

Write(DataTable)

Writes the specified table in a CSV format.
Declaration
public void Write(DataTable table)
Parameters
Type Name Description
System.Data.DataTable table The data table to be written.
| Improve this Doc View Source

Write<T>(T[,])

Writes the specified matrix in CSV format.
Declaration
public void Write<T>(T[, ] table)
Parameters
Type Name Description
T[,] table The table to be written.
Type Parameters
Name Description
T The matrix data type.
| Improve this Doc View Source

Write<T>(IEnumerable<T[]>)

Writes the specified matrix in CSV format.
Declaration
public void Write<T>(IEnumerable<T[]> table)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<T[]> table The table to be written.
Type Parameters
Name Description
T The matrix data type.
| Improve this Doc View Source

WriteHeaders(DataTable)

Writes the column names of a data table as the headers of the CSV file.
Declaration
public void WriteHeaders(DataTable table)
Parameters
Type Name Description
System.Data.DataTable table A DataTable whose columns names will be written as headers.
| Improve this Doc View Source

WriteHeaders(String[])

Writes the column names of a data table as the headers of the CSV file.
Declaration
public void WriteHeaders(params string[] columnNames)
Parameters
Type Name Description
System.String[] columnNames A list of column names to use.
| Improve this Doc View Source

WriteLine<T>(T[], String)

Writes the specified fields in a CSV format.
Declaration
public void WriteLine<T>(T[] fields, string comment)
Parameters
Type Name Description
T[] fields The fields to be written.
System.String comment An optional comment for the line.
Type Parameters
Name Description
T
| Improve this Doc View Source

WriteLine<T>(T[])

Writes the specified fields in a CSV format.
Declaration
public void WriteLine<T>(T[] fields)
Parameters
Type Name Description
T[] fields The fields to be written.
Type Parameters
Name Description
T

Implements

System.IDisposable

Extension Methods

Serializer.Save<T>(T, out Byte[], SerializerCompression)
Serializer.Save<T>(T, Stream, SerializerCompression)
Serializer.Save<T>(T, BinaryFormatter, Stream, SerializerCompression)
Serializer.Save<T>(T, String, SerializerCompression)
Serializer.Save<T>(T, String)
Matrix.Concatenate<T>(T, T[])
Matrix.Replace<T>(T, Object, Object)
DomainDataImporter.Import(Object, InputConfiguration)
ObjectSerialize.Serialize(Object)
Matrix.IsEqual(Object, Object, Decimal, Decimal)
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © MARS GROUP. HAW Hamburg