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 84 11/13/2024
2.0.6-preview1 219 8/8/2024
2.0.5 415 11/19/2023
2.0.4 149 11/18/2023
2.0.2 167 11/14/2023
2.0.1 150 11/13/2023
2.0.0 163 11/12/2023
1.0.10 1,024 10/10/2019
1.0.9 495 10/10/2019
1.0.8 523 10/10/2019
1.0.7 517 10/9/2019
1.0.6 518 10/9/2019
1.0.5 552 9/10/2019
1.0.4 537 9/9/2019
1.0.3 540 9/5/2019
1.0.2 544 8/24/2019
1.0.1 522 8/23/2019
1.0.0 545 8/23/2019