OfficeIMO.CSV
0.1.24
Prefix Reserved
See the version list below for details.
dotnet add package OfficeIMO.CSV --version 0.1.24
NuGet\Install-Package OfficeIMO.CSV -Version 0.1.24
<PackageReference Include="OfficeIMO.CSV" Version="0.1.24" />
<PackageVersion Include="OfficeIMO.CSV" Version="0.1.24" />
<PackageReference Include="OfficeIMO.CSV" />
paket add OfficeIMO.CSV --version 0.1.24
#r "nuget: OfficeIMO.CSV, 0.1.24"
#:package OfficeIMO.CSV@0.1.24
#addin nuget:?package=OfficeIMO.CSV&version=0.1.24
#tool nuget:?package=OfficeIMO.CSV&version=0.1.24
OfficeIMO.CSV — Fluent CSV Document Model
Fluent, strongly typed, AOT-friendly CSV document model aligned with the OfficeIMO ecosystem (Word, Excel, etc.). Targets netstandard2.0, net8.0, net9.0, and net472, with streaming support for large files.
Highlights
- Document-centric API: configure delimiter, header, culture, encoding once; compose transforms fluently.
- Strong typing without reflection:
Get<T>(), helpers (AsString/AsInt32), explicit mapping builder for POCOs/records. - Schema & validation: declare columns, types, required fields, custom rules; validate or throw.
- Streaming mode: lazily enumerate huge CSVs; opt-in materialization for transforms.
- AOT friendly: no
dynamic, no codegen; trimming-safe delegates only.
Why OfficeIMO.CSV instead of hand-rolled CSV code?
- Predictable document model: headers + rows are first-class, so transforms stay consistent (no ad-hoc
List<string[]>). - Validation baked in: schemas with required/optional columns, types, defaults, custom rules; catch issues before exporting/importing downstream.
- Typed mapping without reflection: explicit column→property assignments keep AOT and trimming happy and avoid hidden reflection costs.
- Streaming + materialize on demand: handle multi-GB CSVs lazily, but flip to in-memory only when you need sorting/filtering.
- Fluent ergonomics: chainable APIs mirror other OfficeIMO packages, reducing glue code and one-off parsers.
- Cross-platform, legacy-friendly: netstandard2.0 + net472 + modern TFMs in one package.
Quick start
using OfficeIMO.CSV;
var csv = new CsvDocument()
.WithDelimiter(';')
.WithHeader("Name", "Age", "City")
.AddRow("Przemek", 36, "Mikołów")
.AddRow("Dominika", 30, "Mikołów")
.SortBy("Age")
.Filter(r => r.AsString("City") == "Mikołów")
.Save("people.csv");
Load & parse from text or file:
var doc = CsvDocument.Load("input.csv", new CsvLoadOptions { Delimiter = ';' });
// or
var doc2 = CsvDocument.Parse(csvText);
Load from stream:
using var stream = File.OpenRead("input.csv");
var doc3 = CsvDocument.Load(stream, new CsvLoadOptions { Mode = CsvLoadMode.Stream }, leaveOpen: true);
Transformations
AddRow,AddColumn(name, row => ...),RemoveColumn(name)SortBy("Age"),SortBy<TKey>(r => r.Get<int>("Age"), descending: true)Filter(r => r.AsString("City") == "Mikołów")Transform(doc => ...)for advanced scenarios
Schema & validation
var validated = CsvDocument.Load("input.csv")
.EnsureSchema(schema => schema
.Column("Id").AsInt32().Required()
.Column("Name").AsString().Required()
.Column("Age").AsInt32().Optional()
)
.ValidateOrThrow();
Retrieve errors without throwing:
validated.Validate(out var errors);
Typed mapping (no reflection)
public sealed record Person(int Id, string Name, int Age, string City);
var people = CsvDocument.Load("people.csv")
.Map<Person>(map => map
.FromColumn<int>("Id", (p, v) => p with { Id = v })
.FromColumn<string>("Name", (p, v) => p with { Name = v })
.FromColumn<int>("Age", (p, v) => p with { Age = v })
.FromColumn<string>("City", (p, v) => p with { City = v })
)
.ToList();
Streaming large files
foreach (var row in CsvDocument.Load("large.csv", new CsvLoadOptions
{
Mode = CsvLoadMode.Stream,
HasHeaderRow = true
}).AsEnumerable())
{
var id = row.AsInt32("Id");
// process lazily
}
// Need transforms? Materialize explicitly
var materialized = doc.Materialize().SortBy("Id");
Options at a glance
CsvLoadOptions:Delimiter,HasHeaderRow(default true),TrimWhitespace(default true),AllowEmptyLines,Culture,Encoding,Mode(InMemory/Stream).CsvSaveOptions:Delimiter,IncludeHeader(default true),NewLine,Culture,Encoding.
Install
dotnet add package OfficeIMO.CSV
Not seeing it on NuGet yet? During early development you can add a
ProjectReferencetoOfficeIMO.CSV.csprojin this repo.
Compatibility
- Frameworks:
netstandard2.0,net8.0,net9.0,net472. - Designed to be trimming/NativeAOT friendly on .NET 8+.
| Product | Versions 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. |
-
.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.39 | 165 | 5/27/2026 |
| 0.1.38 | 250 | 5/26/2026 |
| 0.1.37 | 188 | 5/26/2026 |
| 0.1.36 | 200 | 5/23/2026 |
| 0.1.35 | 211 | 5/22/2026 |
| 0.1.34 | 178 | 5/21/2026 |
| 0.1.33 | 184 | 5/21/2026 |
| 0.1.32 | 180 | 5/20/2026 |
| 0.1.31 | 199 | 5/19/2026 |
| 0.1.30 | 181 | 5/18/2026 |
| 0.1.29 | 376 | 5/16/2026 |
| 0.1.28 | 178 | 5/14/2026 |
| 0.1.27 | 378 | 5/14/2026 |
| 0.1.26 | 406 | 5/7/2026 |
| 0.1.25 | 221 | 5/1/2026 |
| 0.1.24 | 204 | 4/27/2026 |
| 0.1.23 | 293 | 4/10/2026 |
| 0.1.22 | 106 | 4/9/2026 |
| 0.1.21 | 305 | 4/3/2026 |
| 0.1.20 | 113 | 4/1/2026 |