bleak.Data.InfiniteDataLoader 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package bleak.Data.InfiniteDataLoader --version 2.0.0
                    
NuGet\Install-Package bleak.Data.InfiniteDataLoader -Version 2.0.0
                    
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="bleak.Data.InfiniteDataLoader" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="bleak.Data.InfiniteDataLoader" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="bleak.Data.InfiniteDataLoader" />
                    
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 bleak.Data.InfiniteDataLoader --version 2.0.0
                    
#r "nuget: bleak.Data.InfiniteDataLoader, 2.0.0"
                    
#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 bleak.Data.InfiniteDataLoader@2.0.0
                    
#: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=bleak.Data.InfiniteDataLoader&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=bleak.Data.InfiniteDataLoader&version=2.0.0
                    
Install as a Cake Tool

bleak.Data.InfiniteDataLoader

Streaming CSV reader, writer and splitter, external sort, and merge join that work on files larger than RAM.

Forward-only, RFC 4180-aware CSV reading and writing with bounded memory, plus the building blocks for working with files that do not fit in RAM:

Type Purpose
CsvReader Forward-only, quoted-field-aware reader.
CsvWriter Writer with correct quoting/escaping.
CsvSplitter Splits a huge file into parts by row count.
ExternalSorter Disk-backed external merge sort on a key column.
MergeJoin Streaming merge join of two key-sorted inputs.
using bleak.Data.InfiniteDataLoader;

using var reader = new CsvReader("customers.csv");          // headers are read up front
int email = reader.IndexOf("email");

foreach (string[] row in reader.ReadRecords())               // one record at a time, bounded memory
{
    Console.WriteLine(CsvWriter.FormatRecord(new[] { row[0], row[email] }));
}

Logging

Every entry point takes an optional logger as its last parameter. It defaults to null, which means no logging. The library depends only on Microsoft.Extensions.Logging.Abstractions, so any provider works.

using Microsoft.Extensions.Logging;

ILoggerFactory loggerFactory = /* from DI, or LoggerFactory.Create(b => b.AddConsole()) */;

var split = CsvSplitter.Split("customers.csv", "out", rowsPerFile: 1_000_000, loggerFactory: loggerFactory);

var sorted = ExternalSorter.SortByLongKey(rows, r => long.Parse(r[0]),
    logger: loggerFactory.CreateLogger(typeof(ExternalSorter)));

var joined = MergeJoin.OneToMany(customers, c => long.Parse(c[0]), orders, o => long.Parse(o[1]),
    onOrphan: orphan => orphanCount++,              // data callback, not logging
    logger: loggerFactory.CreateLogger(typeof(MergeJoin)));

using var reader = new CsvReader("customers.csv", logger: loggerFactory.CreateLogger<CsvReader>());
Category (bleak.Data.InfiniteDataLoader.*) Parameter Information Debug Trace
ExternalSorter ILogger? logger sort started; sort completed (rows, chunks, bytes spilled, DurationMs, rec/s) temp directory; chunk-sort phase and merge phase finished, with DurationMs one line per spilled chunk (rows, bytes, sort/write ms)
CsvSplitter ILoggerFactory? loggerFactory split started; split completed (files, rows, bytes, DurationMs, rec/s) input/output paths; one line per part file (rows, bytes, DurationMs) -
MergeJoin ILogger? logger - join summary: left rows / matched / without children, right rows / matched / orphans, DurationMs -
CsvReader ILogger<CsvReader>? logger - opened (column count); closed (rows, bytes read, DurationMs) -

Warnings: CsvSplitter input with no data rows; ExternalSorter temp directory that could not be deleted. Errors: a sort or split that throws is logged with the exception (and rethrown).

Event IDs: 1000-1099 CsvReader, 1200-1299 CsvSplitter, 1300-1399 ExternalSorter, 1400-1499 MergeJoin. CsvWriter is a stateless formatter and does not log.

Notes for performance work:

  • Nothing is ever logged per row. Messages use source-generated [LoggerMessage] methods, so a disabled level costs nothing. CsvReader only counts rows while Debug is enabled.
  • ExternalSorter and MergeJoin are lazy, so their DurationMs is wall-clock time from the first record to the last. It includes producing their input and whatever the caller does between records. The ExternalSorter merge-phase Debug line splits that into MergeMs and ConsumerMs, and the chunk-sort Debug line reports SortMs and WriteMs (the rest of that phase is time spent reading the input).

Data guarantee: at Debug and above, the library logs only metadata: counts, byte sizes, durations, file names and paths, and column counts. Field values, keys and record contents are never logged at any level.

Upgrading from 1.x

2.0.0 replaces the Action<string>? log callbacks with Microsoft.Extensions.Logging:

1.x 2.0
CsvSplitter.Split(..., Action<string>? log = null) CsvSplitter.Split(..., ILoggerFactory? loggerFactory = null)
ExternalSorter.SortByLongKey(..., Action<string>? log = null) ExternalSorter.SortByLongKey(..., ILogger? logger = null)
ExternalSorter.SortByKey<TKey>(..., Action<string>? log = null) ExternalSorter.SortByKey<TKey>(..., ILogger? logger = null)
ExternalSorter.SortByStringKey(..., Action<string>? log = null, IComparer<string>? comparer = null) ExternalSorter.SortByStringKey(..., IComparer<string>? comparer = null, ILogger? logger = null)

MergeJoin.OneToMany and the CsvReader constructors gained an optional logger as their last parameter. SortByKey, SortByLongKey and SortByStringKey now reject chunkSize <= 0 when called, not on first enumeration.

Install

dotnet add package bleak.Data.InfiniteDataLoader

License

The Unlicense (public domain).

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on bleak.Data.InfiniteDataLoader:

Package Downloads
bleak.Data.Transformer

Config-driven, streaming ETL engine: describe sources, joins, typed fields and transform pipelines in JSON and get JSONL out.

bleak.Data.Anonymizer

Config-driven PII anonymizer for large delimited files: fake names, emails, phones, dates, addresses, GUIDs and more.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 127 11/6/2026
2.0.1 123 11/3/2026
2.0.0 139 10/19/2026
1.0.0 133 10/13/2026