OfficeIMO.CSV 0.1.46

Prefix Reserved
dotnet add package OfficeIMO.CSV --version 0.1.46
                    
NuGet\Install-Package OfficeIMO.CSV -Version 0.1.46
                    
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="OfficeIMO.CSV" Version="0.1.46" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OfficeIMO.CSV" Version="0.1.46" />
                    
Directory.Packages.props
<PackageReference Include="OfficeIMO.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 OfficeIMO.CSV --version 0.1.46
                    
#r "nuget: OfficeIMO.CSV, 0.1.46"
                    
#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 OfficeIMO.CSV@0.1.46
                    
#: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=OfficeIMO.CSV&version=0.1.46
                    
Install as a Cake Addin
#tool nuget:?package=OfficeIMO.CSV&version=0.1.46
                    
Install as a Cake Tool

OfficeIMO.CSV - fluent CSV document model

nuget version nuget downloads

OfficeIMO.CSV is a fluent, strongly typed CSV document model aligned with the OfficeIMO ecosystem. It supports in-memory transforms, streaming reads, schemas, validation, typed mapping, and AOT-friendly explicit selectors.

Install

dotnet add package OfficeIMO.CSV

Quick start

using OfficeIMO.CSV;
using System.Globalization;

new CsvDocument()
    .WithDelimiter(';')
    .WithCulture(CultureInfo.InvariantCulture)
    .WithHeader("Name", "Age", "City")
    .AddRow("Przemek", 36, "Mikolow")
    .AddRow("Dominika", 30, "Mikolow")
    .AddColumn("Bucket", row => row.AsInt32("Age") >= 35 ? "Senior" : "Regular")
    .SortBy("Age")
    .Filter(row => row.AsString("City") == "Mikolow")
    .Save("people.csv", new CsvSaveOptions {
        Delimiter = ';',
        IncludeHeader = true,
        NewLine = "\n"
    });

What it does

  • Keeps headers and rows as a first-class document model instead of ad hoc string arrays.
  • Loads from files, streams, or text and saves through configurable delimiter, culture, encoding, and newline options.
  • Supports AddRow, AddColumn, RemoveColumn, SortBy, Filter, and Transform.
  • Provides schema validation with required columns, typed columns, defaults, and custom rules.
  • Maps rows to typed objects with explicit no-reflection mapping.
  • Supports streaming mode for large files and explicit materialization when transforms are needed.

Schema example

var document = CsvDocument.Load("input.csv")
    .EnsureSchema(schema => schema
        .Column("Id").AsInt32().Required()
        .Column("Name").AsString().Required()
        .Column("Age").AsInt32().Optional())
    .ValidateOrThrow();

Collect validation errors without throwing when an import pipeline should report all bad rows:

var document = CsvDocument.Load("input.csv")
    .EnsureSchema(schema => schema
        .Column("Id").AsInt32().Required()
        .Column("Name").AsString().Required()
        .Column("Age").AsInt32().Optional()
        .Column("Active").AsBoolean().WithDefault(true));

document.Validate(out var errors);
foreach (var error in errors) {
    Console.WriteLine($"{error.RowIndex}:{error.ColumnName} - {error.Message}");
}

Typed mapping

Mapping is explicit and delegate-based, so it stays predictable for trimming and NativeAOT-sensitive applications.

using OfficeIMO.CSV;

List<Person> people = CsvDocument.Load("people.csv")
    .Map<Person>(map => map
        .FromColumn<int>("Id", (person, value) => {
            person.Id = value;
            return person;
        })
        .FromColumn<string>("Name", (person, value) => {
            person.Name = value;
            return person;
        })
        .FromColumn<int>("Age", (person, value) => {
            person.Age = value;
            return person;
        })
        .FromColumn<string>("City", (person, value) => {
            person.City = value;
            return person;
        }))
    .ToList();

public sealed class Person {
    public int Id { get; set; }
    public string Name { get; set; } = "";
    public int Age { get; set; }
    public string City { get; set; } = "";
}

For immutable models, return a new instance from each assignment:

using OfficeIMO.CSV;

var people = CsvDocument.Load("people.csv")
    .Map<PersonRecord>(map => map
        .FromColumn<int>("Id", (person, value) => person with { Id = value })
        .FromColumn<string>("Name", (person, value) => person with { Name = value }))
    .ToList();

public sealed record PersonRecord {
    public int Id { get; init; }
    public string Name { get; init; } = "";
}

Streaming and materializing

Use streaming mode when the caller only needs forward-only row processing.

foreach (var row in CsvDocument.Load("large.csv", new CsvLoadOptions {
    Mode = CsvLoadMode.Stream,
    HasHeaderRow = true,
    TrimWhitespace = true
}).AsEnumerable()) {
    int id = row.AsInt32("Id");
    string? status = row.AsString("Status");
    Console.WriteLine($"{id}: {status}");
}

Transforms such as SortBy, Filter, and AddColumn require in-memory mode. Materialize deliberately when that is the desired tradeoff:

var transformed = CsvDocument.Load("large.csv", new CsvLoadOptions {
        Mode = CsvLoadMode.Stream
    })
    .Materialize()
    .AddColumn("ImportedUtc", _ => DateTime.UtcNow)
    .Filter(row => row.AsString("Status") == "Ready")
    .SortBy(row => row.AsInt32("Id"));

transformed.Save("ready.csv");

Objects and ad hoc data

FromObjects is useful for small exports from anonymous objects, DTOs, or dictionaries:

var rows = new[] {
    new { Name = "Alpha", Count = 10, Active = true },
    new { Name = "Beta", Count = 20, Active = false }
};

CsvDocument.FromObjects(rows)
    .Save("summary.csv");

Parse text when a service receives CSV payloads without a temporary file:

string payload = "Name,Amount\nAlpha,10\nBeta,20";

var document = CsvDocument.Parse(payload)
    .AddColumn("Currency", _ => "EUR");

string normalized = document.ToString(new CsvSaveOptions {
    Delimiter = ',',
    IncludeHeader = true
});

Boundaries

  • This package owns CSV parsing, writing, transforms, and validation.
  • Reader integration belongs in OfficeIMO.Reader.Csv.
  • Excel workbook behavior belongs in OfficeIMO.Excel.

Targets and license

  • Targets: netstandard2.0, net8.0, net10.0, net472.
  • License: MIT.
  • Repository: EvotecIT/OfficeIMO
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on OfficeIMO.CSV:

Package Downloads
OfficeIMO.Reader.Csv

CSV/TSV adapter extensions for OfficeIMO.Reader.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on OfficeIMO.CSV:

Repository Stars
EvotecIT/PSWriteOffice
PowerShell Module to create and edit Microsoft Word, Microsoft Excel, and Microsoft PowerPoint documents without having Microsoft Office installed.
Version Downloads Last Updated
0.1.46 108 6/16/2026
0.1.45 258 6/16/2026
0.1.44 219 6/15/2026
0.1.43 253 6/13/2026
0.1.42 277 6/12/2026
0.1.41 190 6/9/2026
0.1.40 197 6/5/2026
0.1.39 350 5/27/2026
0.1.38 259 5/26/2026
0.1.37 191 5/26/2026
0.1.36 203 5/23/2026
0.1.35 215 5/22/2026
0.1.34 181 5/21/2026
0.1.33 187 5/21/2026
0.1.32 183 5/20/2026
0.1.31 201 5/19/2026
0.1.30 186 5/18/2026
0.1.29 394 5/16/2026
0.1.28 180 5/14/2026
0.1.27 384 5/14/2026
Loading failed