Enigmatry.Entry.Csv 9.1.1-preview.4

This is a prerelease version of Enigmatry.Entry.Csv.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Enigmatry.Entry.Csv --version 9.1.1-preview.4
                    
NuGet\Install-Package Enigmatry.Entry.Csv -Version 9.1.1-preview.4
                    
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="Enigmatry.Entry.Csv" Version="9.1.1-preview.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Enigmatry.Entry.Csv" Version="9.1.1-preview.4" />
                    
Directory.Packages.props
<PackageReference Include="Enigmatry.Entry.Csv" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Enigmatry.Entry.Csv --version 9.1.1-preview.4
                    
#r "nuget: Enigmatry.Entry.Csv, 9.1.1-preview.4"
                    
#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.
#:package Enigmatry.Entry.Csv@9.1.1-preview.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Enigmatry.Entry.Csv&version=9.1.1-preview.4&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Enigmatry.Entry.Csv&version=9.1.1-preview.4&prerelease
                    
Install as a Cake Tool

CSV Processing Library

A library that provides functionality for reading and writing CSV files, with support for complex mapping, validation, and transformation.

Intended Usage

Use this library when you need to import or export data in CSV format, with strong typing and customizable mapping between your domain models and CSV records.

Installation

Add the package to your project:

dotnet add package Enigmatry.Entry.Csv

Usage Examples

Reading a CSV file:

using System;
using System.IO;
using System.Collections.Generic;
using Enigmatry.Entry.Csv;

// Define your model
public class Person
{
    public string FirstName { get; set; } = string.Empty;
    
    [Name("Last Name")]
    public string LastName { get; set; } = string.Empty;
    
    [Name("Date of Birth")]
    public DateTime BirthDate { get; set; }
    
    [Name("Email Address")]
    public string Email { get; set; } = string.Empty;
    
    [Ignore]
    public string InternalId { get; set; } = string.Empty;
}

// Read CSV file
public List<Person> ReadPeopleFromCsv(string filePath)
{
    // Create CSV helper with options
    var csvHelper = new CsvHelper<Person>(options => 
    {
        options.WithCulture(System.Globalization.CultureInfo.InvariantCulture);
    });
    
    using var fileStream = File.OpenRead(filePath);
    var people = csvHelper.GetRecords(fileStream).ToList();
    
    return people;
}

Writing a CSV file:

using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using Enigmatry.Entry.Csv;

// Create some data
var people = new List<Person>
{
    new Person 
    { 
        FirstName = "John", 
        LastName = "Doe", 
        BirthDate = new DateTime(1980, 1, 1), 
        Email = "john@example.com",
        InternalId = "JD001" // This will be ignored in the CSV output because of the [Ignore] attribute
    },
    new Person 
    { 
        FirstName = "Jane", 
        LastName = "Smith", 
        BirthDate = new DateTime(1985, 5, 5), 
        Email = "jane@example.com",
        InternalId = "JS002" 
    }
};

// Write to CSV file
public void ExportPeopleToCsv(List<Person> people, string outputFilePath)
{
    var csvHelper = new CsvHelper<Person>(options => 
    {
        options.WithEncoding(Encoding.UTF8);
        options.WithCulture(System.Globalization.CultureInfo.InvariantCulture);
    });
    
    // Generate CSV data
    byte[] csvData = csvHelper.WriteRecords(people);
    
    // Save to file
    File.WriteAllBytes(outputFilePath, csvData);
}

Additional Examples

Working with DateTimeOffset values:

using System;
using System.Collections.Generic;
using Enigmatry.Entry.Csv;

public class Event
{
    public string Name { get; set; } = string.Empty;
    
    [Name("Event Time")]
    public DateTimeOffset EventTime { get; set; }
}

public void ProcessEventsCsv(string filePath)
{
    // The built-in DateTimeOffsetToLocalDateTimeConverter will automatically handle converting 
    // DateTimeOffset values to local date-time strings when writing CSV data
    var csvHelper = new CsvHelper<Event>(options => 
    {
        options.WithCulture(System.Globalization.CultureInfo.InvariantCulture);
    });
    
    // Example writing events with DateTimeOffset
    var events = new List<Event>
    {
        new Event { Name = "Conference", EventTime = DateTimeOffset.Now },
        new Event { Name = "Workshop", EventTime = DateTimeOffset.Now.AddDays(1) }
    };
    
    byte[] csvData = csvHelper.WriteRecords(events);
    
    // CSV will show local dates in "yyyy-MM-dd HH:mm:ss" format
}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
9.1.1-preview.5 169 8/8/2025
9.1.1-preview.4 91 6/27/2025
9.1.1-preview.3 124 6/4/2025
9.1.0 567 6/3/2025
9.0.1-preview.8 129 5/26/2025
9.0.1-preview.7 215 5/13/2025
9.0.1-preview.6 274 5/9/2025
9.0.1-preview.5 151 5/7/2025
9.0.1-preview.4 127 4/30/2025
9.0.1-preview.2 131 4/1/2025
9.0.0 649 2/26/2025
8.1.1-preview.3 124 5/7/2025
8.1.1-preview.1 133 4/1/2025
8.1.0 339 2/19/2025
8.0.1-preview.4 84 2/7/2025
8.0.1-preview.2 500 1/15/2025
8.0.0 754 11/27/2024
3.4.6-preview.10 72 11/27/2024
3.4.3 836 10/22/2024
3.4.2 446 10/11/2024
3.4.1 142 10/9/2024
3.4.0 128 10/9/2024
3.3.2 153 8/28/2024
3.3.2-preview.7 77 8/27/2024
3.3.1 140 7/16/2024
3.3.1-preview.4 68 7/12/2024
3.3.0 1,131 6/20/2024
3.2.1-preview.4 74 6/17/2024
3.2.1-preview.1 91 5/23/2024
3.2.0 3,365 4/3/2024
3.1.1-preview.1 80 3/13/2024
3.1.0 941 3/8/2024
3.1.0-preview.2 88 2/19/2024
3.0.1-preview.2 109 2/9/2024
3.0.1-preview.1 85 1/24/2024
3.0.0 489 1/15/2024
3.0.0-preview.14 87 1/9/2024
3.0.0-preview.12 83 1/9/2024
3.0.0-preview.5 82 1/10/2024
3.0.0-preview.2 97 12/28/2023
3.0.0-preview 133 12/20/2023
2.1.0 192 12/28/2023
2.0.1-preview.3 125 12/1/2023
2.0.1-preview.2 94 11/29/2023
2.0.1-preview.1 91 11/28/2023
2.0.0 402 11/8/2023
2.0.0-preview.3 106 10/27/2023
2.0.0-preview.2 93 10/27/2023
2.0.0-preview.1 94 10/27/2023
2.0.0-preview 143 10/27/2023
1.1.500 164 10/27/2023
1.1.495 194 9/24/2023
1.1.486 196 9/13/2023
1.1.484 200 9/7/2023
1.1.482 200 9/6/2023
1.1.480 206 8/24/2023
1.1.477 255 8/2/2023
1.1.464 220 7/5/2023
1.1.447 239 5/26/2023
1.1.396 319 4/11/2023
1.1.383 283 4/3/2023
1.1.377 273 3/13/2023
1.1.376 284 3/13/2023
1.1.365 547 2/15/2023