FlatFileMonger 1.0.3

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

FlatFileMonger

FlatFileMonger is a deterministic CSV and fixed-width flat file engine designed to handle real-world, inconsistent, and irregular data exports without relying on schema inference or implicit conversions.

The parser operates as a tokenizing state machine with explicit rules for delimiters, quoting, whitespace, and newline handling. Error recovery and record alignment are controlled by configuration.

Core behavior

  • Explicit tokenization (Value, QuotedValue, Comma, NewLine, Comment, Invalid)
  • Deterministic parsing with no implicit type conversion
  • Configurable delimiter, quote character, whitespace handling, and newline mode
  • One-time newline detection in Auto mode, then deterministic behavior
  • Full CSV-compatible quoted field handling, including embedded CR/LF
  • Plain field parsing with optional trailing whitespace trimming
  • Hash-prefixed comment lines (#...) supported
  • Invalid tokens trigger controlled recovery (skip to next newline)

Record handling

  • Optional header row; can be overridden with a predefined schema
  • Duplicate column names handled by configurable mode (Ignore, Rename, Disallow)
  • Field count autodetected from the first record unless explicitly set
  • Sparse records:
    • If enabled: missing fields are padded with null or the configured default
    • If disabled: missing fields raise a CsvFormatException
  • Long records:
    • If enabled: extra fields are accepted
    • If disabled: extra fields raise a CsvFormatException
  • Optional trailer row detection (TRAILER<n>), with row count validation

Error handling

  • Read() throws CsvFormatException on malformed input
  • TryRead() captures the error and continues parsing
  • Automatic resynchronization after errors (skip to next newline)
  • Invalid tokens never terminate the parser; recovery is explicit and predictable

Typical usage

var options = new CsvFormatOptions()
{
    Encoding = Encoding.UTF8,
    HasHeaderRow = true,
    Delimiter = ',',
    QuoteChar = '"',
    PreserveWhiteSpace = false,
    NewLineMode = NewLineModeEnum.Auto,
};

using var reader = new CsvReader("data.csv", options);

if (reader.ReadHeader())
{
    while (reader.Read())
    {
        Console.WriteLine($"{reader["date"]}: {reader["message"]}");
    }
}

When to use FlatFileMonger

FlatFileMonger is designed for environments where CSV input is:

  • inconsistent,
  • irregular,
  • partially malformed,
  • or produced by systems that do not strictly follow CSV conventions.

If a human can still interpret the file, FlatFileMonger will likely parse it under the configured rules.

License

Apache License 2.0. See LICENSE for details.

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 was computed.  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 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. 
.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 was computed.  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.
  • .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
1.0.3 132 8/24/2026