RG.CsvSerializer 2.0.6

dotnet add package RG.CsvSerializer --version 2.0.6                
NuGet\Install-Package RG.CsvSerializer -Version 2.0.6                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RG.CsvSerializer" Version="2.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RG.CsvSerializer --version 2.0.6                
#r "nuget: RG.CsvSerializer, 2.0.6"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RG.CsvSerializer as a Cake Addin
#addin nuget:?package=RG.CsvSerializer&version=2.0.6

// Install RG.CsvSerializer as a Cake Tool
#tool nuget:?package=RG.CsvSerializer&version=2.0.6                

CsvSerializer: The Fastest CSV Serializer for .NET

NuGet

Installation

Package Manager Console:

Install-Package RG.CsvSerializer

Usage

using Csv;

// Serialize collection to CSV string
string csv = CsvSerializer.Serialize(items, withHeaders: true);

// Deserialize CSV string to array
Item[] items = CsvSerializer.Deserialize<Item>(csv, hasHeaders: true);

With custom delimiter:

Item[] items = CsvSerializer.Deserialize<Item>(csv, hasHeaders: true, separator: ';');

With custom header name and date format:

class Product {
    public string Name { get; set; }
    
    [CsvColumn("Price")]
    public decimal PriceBeforeTaxes { get; set; }
    
    [CsvColumn("Added", DateFormat = "dd/MM/yyyy")]
    public DateTime Added { get; set; }
}

Serializing to stream:

CsvSerializer.Serialize(streamWriter, items, withHeaders: true);

Deserializing from stream:

IEnumerable<Item> items = CsvSerializer.Deserialize<Item>(streamReader, hasHeaders: true);

Supported Property Types

bool
bool?
byte
byte?
sbyte
sbyte?
short
short?
ushort
ushort?
int
int?
uint
uint?
long
long?
ulong
ulong?
float
float?
double
double?
decimal
decimal?
string
DateTime
DateTime?
Uri // serialized as quoted string
Enum // serialized as unquoted string
Enum? // serialized as unquoted string

Not yet supported:

char
char?
DateTimeOffset
DateTimeOffset?
TimeSpan
TimeSpan?
Guid
Guid?
any Object to string (serialize only)
any Object to JSON
any Object to MessagePack Base64
any Object to MessagePack Hex string
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.6 98 11/13/2024
2.0.6-preview1 221 8/8/2024
2.0.5 419 11/19/2023
2.0.4 153 11/18/2023
2.0.2 171 11/14/2023
2.0.1 154 11/13/2023
2.0.0 167 11/12/2023
1.0.10 1,028 10/10/2019
1.0.9 499 10/10/2019
1.0.8 527 10/10/2019
1.0.7 521 10/9/2019
1.0.6 522 10/9/2019
1.0.5 556 9/10/2019
1.0.4 541 9/9/2019
1.0.3 544 9/5/2019
1.0.2 548 8/24/2019
1.0.1 526 8/23/2019
1.0.0 549 8/23/2019