Csv 2.0.205

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

csv

NuGet Version NuGet Downloads Build status codecov

Really simple csv library

This library targets .NET Standard 2.0, .NET 8.0, and .NET 9.0, with enhanced Span/Memory APIs available for .NET 8.0+.

Install

To install csv, use the following command in the Package Manager Console

PM> Install-Package Csv

Basic Usage

More examples can be found in the tests.

Reading a CSV file

// NOTE: Library assumes that the csv data will have a header row by default, see CsvOptions.HeaderMode
/*
# comments are ignored
Column name,Second column,Third column
First cell,second cell,
Second row,second cell,third cell
*/ 
var csv = File.ReadAllText("sample.csv");
foreach (var line in CsvReader.ReadFromText(csv))
{
    // Header is handled, each line will contain the actual row data
    var firstCell = line[0];
    var byName = line["Column name"];
}

CsvReader also supports reading from a TextReader (CsvReader.Read(TextReader, CsvOptions)) or a Stream (CsvReader.ReadFromStream(Stream, CsvOptions))

For .NET 8.0+ the library exposes:

  • CsvReader.ReadAsync and CsvReader.ReadFromStreamAsync which return IAsyncEnumerable<ICsvLine>
  • CsvReader.ReadFromMemory to read from a ReadOnlyMemory<char> without allocating intermediate strings
  • CsvReader.ReadAsSpan, CsvReader.ReadFromStreamAsSpan, and CsvReader.ReadFromTextAsSpan which return IEnumerable<ICsvLineSpan> for zero-allocation Span/Memory access to CSV data
  • CsvReader.ReadFromMemoryOptimized with CsvMemoryOptions for high-performance scenarios using ArrayPool-based buffering
High-performance reading with Span/Memory (.NET 8.0+)
var csv = File.ReadAllText("sample.csv");
foreach (var line in CsvReader.ReadFromTextAsSpan(csv))
{
    // Access data as ReadOnlySpan<char> for zero allocations
    ReadOnlySpan<char> firstCell = line.GetSpan(0);
    ReadOnlySpan<char> byName = line.GetSpan("Column name");

    // Or as ReadOnlyMemory<char> if you need to store references
    ReadOnlyMemory<char> cellMemory = line.GetMemory(0);
}

CsvOptions can be used to configure the csv parsing:

var options = new CsvOptions // Defaults
{
    RowsToSkip = 0, // Allows skipping of initial rows without csv data
    SkipRow = (row, idx) => string.IsNullOrEmpty(row) || row[0] == '#',
    Separator = '\0', // Autodetects based on first row
    TrimData = false, // Can be used to trim each cell
    Comparer = null, // Can be used for case-insensitive comparison for names
    HeaderMode = HeaderMode.HeaderPresent, // Assumes first row is a header row
    ValidateColumnCount = false, // Checks each row immediately for column count
    ReturnEmptyForMissingColumn = false, // Allows for accessing invalid column names
    Aliases = null, // A collection of alternative column names
    AllowNewLineInEnclosedFieldValues = false, // Respects new line (either \r\n or \n) characters inside field values enclosed in double quotes.
    AllowBackSlashToEscapeQuote = false, // Allows the sequence "\"" to be a valid quoted value (in addition to the standard """")
    AllowSingleQuoteToEncloseFieldValues = false, // Allows the single-quote character to be used to enclose field values
    NewLine = Environment.NewLine // The new line string to use when multiline field values are read (Requires "AllowNewLineInEnclosedFieldValues" to be set to "true" for this to have any effect.)
};

Writing a CSV file

With headers
var columnNames = new [] { "Id", "Name" };
var rows = new []
{
    new [] { "0", "John Doe" },
    new [] { "1", "Jane Doe" }
};
var csv = CsvWriter.WriteToText(columnNames, rows, ',');
File.WriteAllText("people.csv", csv);
/*
Writes the following to the file:

Id,Name
0,John Doe
1,Jane Doe
*/
Without headers
var rows = new []
{
    new [] { "0", "John Doe" },
    new [] { "1", "Jane Doe" }
};
// Convenience overload - no need to pass headers or skipHeaderRow
var csv = CsvWriter.WriteToText(rows);
File.WriteAllText("people.csv", csv);
/*
Writes the following to the file (no header row):

0,John Doe
1,Jane Doe
*/
Skipping headers
var columnNames = new [] { "Id", "Name" };
var rows = new []
{
    new [] { "0", "John Doe" },
    new [] { "1", "Jane Doe" }
};
// Pass null for headers and skipHeaderRow: true
// Column count is determined from the first data row
var csv = CsvWriter.WriteToText(null, rows, ',', skipHeaderRow: true);
Custom separator
var rows = new [] { new [] { "A", "B" }, new [] { "C", "D" } };
var csv = CsvWriter.WriteToText(rows, ';'); // semicolon separator
// Output: A;B
//         C;D

CsvWriter also includes asynchronous overloads (WriteAsync and WriteToTextAsync) which operate on IAsyncEnumerable<string[]> and support passing a CancellationToken. For .NET 8.0+, memory-efficient overloads using ReadOnlyMemory<char> are available.

Helper extensions

CsvReader provides extension methods to work with the returned IEnumerable<ICsvLine>:

  • GetColumn(int columnNo) / GetColumn<T>(int columnNo, Func<string, T>) – extract a single column from all rows.
  • GetBlock(int row_start = 0, int row_length = -1, int col_start = 0, int col_length = -1) – get a rectangular subset of the data.

Status

NuGet Version NuGet Downloads Build status codecov FOSSA Status

License

FOSSA Status

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 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. 
.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.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on Csv:

Package Downloads
Reo.Core.DataImport

Package Description

Zebra.Printer.SDK

The Zebra Link-OS SDK provides a powerful set of APIs enabling creation of desktop and mobile apps that take full advantage of the printer's operating system features including connectivity, printing and management tasks.

Prime

An F# code library for pure functional programming... and much more!

Prime.Scripting

A dynamic scripting language for .NET.

Khaos.Avalanche

Package Description

GitHub repositories (6)

Showing the top 6 popular GitHub repositories that depend on Csv:

Repository Stars
dotnet/ai-samples
darklinkpower/PlayniteExtensionsCollection
Collection of extensions made for Playnite.
mattfrear/Swashbuckle.AspNetCore.Filters
A bunch of useful filters for Swashbuckle.AspNetCore
tukasa0001/TownOfHost
Host only mod for Among Us.
amrshaheen61/UE4LocalizationsTool
simple tool to edit unreal engine 4 text files
akintos/UnrealLocres
UE4 localization resource file tool
Version Downloads Last Updated
2.0.205 2,395 10/21/2025
2.0.170 44,828 5/20/2025
2.0.128 69,959 2/20/2025
2.0.93 1,008,707 12/10/2022
2.0.87 269,553 9/2/2022
2.0.84 168,399 5/4/2022
2.0.80 12,322 4/21/2022
2.0.76 1,148 4/21/2022
2.0.67 19,795 3/31/2022
2.0.65 53,198 1/18/2022
2.0.64 3,895 1/4/2022
2.0.62 201,811 12/24/2020
2.0.61 49,849 12/23/2020