PocketCsvReader 2.27.11
See the version list below for details.
dotnet add package PocketCsvReader --version 2.27.11
NuGet\Install-Package PocketCsvReader -Version 2.27.11
<PackageReference Include="PocketCsvReader" Version="2.27.11" />
paket add PocketCsvReader --version 2.27.11
#r "nuget: PocketCsvReader, 2.27.11"
// Install PocketCsvReader as a Cake Addin #addin nuget:?package=PocketCsvReader&version=2.27.11 // Install PocketCsvReader as a Cake Tool #tool nuget:?package=PocketCsvReader&version=2.27.11
PocketCsvReader
PocketCsvReader is a highly efficient and lightweight library tailored for parsing delimited flat files like CSV and TSV. With a focus on simplicity and performance, it offers seamless file reading and supports versatile outputs, including DataTables, string arrays, strongly-typed object mapping and an IDataReader interface. Designed for projects requiring rapid data ingestion with minimal configuration, PocketCsvReader is a dependable solution for handling structured flat-file data effortlessly.
About | Install | Quick-start
About
Continuous integration builds:
Install
Replace <VersionNumber>
with the desired version in each of the following solutions. If no version is specified, the latest version will be installed.
NuGet CLI
Open a command prompt or terminal.
Run the following command:
nuget install PocketCsvReader -Version <VersionNumber>
Visual Studio Package Manager Console
Open the Package Manager Console from Tools > NuGet Package Manager > Package Manager Console.
Run the following command:
Install-Package PocketCsvReader -Version <VersionNumber>
Dotnet-CLI
Open a terminal or command prompt.
Navigate to the directory of your project.
Run the following command:
dotnet add package PocketCsvReader --version <VersionNumber>
Quick-start
The CsvReader
class is a flexible and efficient tool for reading and parsing CSV files or streams into various formats, such as DataTable
, IDataReader
, or strongly-typed objects. This documentation explains the basics of how to use the class, including common use cases and examples.
Features
- Read CSV files or streams into a
DataTable
. - Access CSV data in a forward-only, read-only manner using
IDataReader
. - Map CSV records to strongly-typed objects.
- Map CSV records to array of strings.
- Customizable CSV parsing profiles for delimiters, quote handling, and more.
- Supports encoding detection through the
IEncodingDetector
interface.
Initialization
You can create an instance of CsvReader
with various configurations:
// Default configuration: comma-delimited, double quotes for escaping, 4 KB buffer size.
var csvReader = new CsvReader();
// Custom CSV profile (e.g., semicolon-delimited, double quotes for escaping).
var csvReaderWithProfile = new CsvReader(CsvProfile.SemiColumnDoubleQuote);
// Custom buffer size for large files.
var csvReaderWithBuffer = new CsvReader(bufferSize: 64 * 1024);
// Both custom profile and buffer size.
var csvReaderCustom = new CsvReader(CsvProfile.SemiColumnDoubleQuote, bufferSize: 16 * 1024);
Reading CSV Data
Reading Into a DataTable
The ToDataTable
method reads CSV data and returns a DataTable
containing all rows and fields.
DataTable dataTable = csvReader.ToDataTable("example.csv");
or to read from a stream,
using var stream = new FileStream("example.csv", FileMode.Open, FileAccess.Read);
DataTable dataTable = csvReader.ToDataTable(stream);
Accessing Data with IDataReader
The ToDataReader
method provides a forward-only, read-only CsvDataReader
implementing IDataReader
for processing large files efficiently.
using var stream = new FileStream("example.csv", FileMode.Open, FileAccess.Read);
using var reader = csvReader.ToDataReader(stream);
while (reader.Read())
{
Console.WriteLine(reader[0]); // Access the first column of the current row.
Console.WriteLine(reader.GetDateTime(1)); // Access the second column of the current row as an object boxing a DateTime.
Console.WriteLine(reader.GetFieldValue<DateOnly>(2); // Access the third column of the current row as DateOnly.
}
Reading as Arrays
using var stream = new FileStream("example.csv", FileMode.Open, FileAccess.Read);
foreach (var record in csvReader.ToArrayString(stream))
{
Console.WriteLine(string.Join(", ", record));
}
Mapping Records to Strongly-Typed Objects
The To<T>
method maps CSV records to objects of a specified type.
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
using var stream = new FileStream("example.csv", FileMode.Open, FileAccess.Read);
IEnumerable<Person> people = csvReader.To<Person>(stream);
foreach (var person in people)
{
Console.WriteLine($"{person.FirstName} {person.LastName}, Age: {person.Age}");
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on PocketCsvReader:
Package | Downloads |
---|---|
NBi.Framework.Tools
This package contains the NBi framework and references each dll to your project. This package is not intended to be directly used by end-users willing to create test-suites. Check the package NBi.VisualStudio, if you want to facilitate the usage of NBi from Visual Studio. NBi is a testing framework (add-on to NUnit) for Business Intelligence and Data Quality. It supports the Microsoft Data platform (SQL Server Database engine, SSIS, SSAS, SSRS) but also MySQL, PostgreSQL and other NoSQL solutions. |
|
Didot.Core
Package Description |
|
Packata.ResourceReaders
Packata is a library for consuming Data Package v2 files. The `Packata.ResourceReaders` package specializes in providing read access to resource files using common patterns, such as `IDataReader`, ensuring seamless data retrieval and processing. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.29.0 | 52 | 3/29/2025 |
2.28.0 | 51 | 3/29/2025 |
2.27.11 | 377 | 3/18/2025 |
2.27.10 | 488 | 3/10/2025 |
2.27.9 | 210 | 3/9/2025 |
2.27.8 | 235 | 3/9/2025 |
2.27.7 | 383 | 2/24/2025 |
2.27.6 | 264 | 2/21/2025 |
2.27.5 | 145 | 2/21/2025 |
2.27.4 | 307 | 2/18/2025 |
2.27.3 | 187 | 2/16/2025 |
2.27.2 | 211 | 2/10/2025 |
2.27.1 | 167 | 2/9/2025 |
2.27.0 | 126 | 2/9/2025 |
2.26.3 | 189 | 2/5/2025 |
2.26.2 | 146 | 2/4/2025 |
2.26.1 | 189 | 2/3/2025 |
2.26.0 | 175 | 2/2/2025 |
2.25.1 | 221 | 1/20/2025 |
2.25.0 | 150 | 1/19/2025 |
2.24.0 | 157 | 1/18/2025 |
2.23.0 | 216 | 1/12/2025 |
2.22.1 | 174 | 1/11/2025 |
2.22.0 | 116 | 1/11/2025 |
2.21.0 | 208 | 1/6/2025 |
2.20.2 | 118 | 1/6/2025 |
2.20.1 | 129 | 1/5/2025 |
2.20.0 | 139 | 1/5/2025 |
2.19.0 | 125 | 1/5/2025 |
2.18.1 | 121 | 1/5/2025 |
2.18.0 | 141 | 1/5/2025 |
2.17.0 | 154 | 1/4/2025 |
2.16.0 | 148 | 1/4/2025 |
2.15.0 | 135 | 1/4/2025 |
2.14.4 | 176 | 12/31/2024 |
2.14.2 | 156 | 12/30/2024 |
2.14.1 | 244 | 12/27/2024 |
2.14.0 | 176 | 12/27/2024 |
2.13.1 | 145 | 12/26/2024 |
2.13.0 | 257 | 12/22/2024 |
2.12.0 | 175 | 12/21/2024 |
2.11.1 | 193 | 12/17/2024 |
2.11.0 | 168 | 12/15/2024 |
2.10.0 | 123 | 12/14/2024 |
2.9.7 | 130 | 12/13/2024 |
2.9.4 | 230 | 11/30/2024 |
2.9.3 | 133 | 11/30/2024 |
2.9.2 | 122 | 11/30/2024 |
2.9.0 | 124 | 11/30/2024 |
2.8.2 | 145 | 11/24/2024 |
2.8.1 | 144 | 11/23/2024 |
2.8.0 | 235 | 11/17/2024 |
2.7.1 | 126 | 11/16/2024 |
2.7.0 | 122 | 11/16/2024 |
2.6.0 | 129 | 11/16/2024 |
2.5.2 | 132 | 11/16/2024 |
2.5.1 | 133 | 11/15/2024 |
2.5.0 | 133 | 11/15/2024 |
2.4.3 | 130 | 11/14/2024 |
2.4.2 | 133 | 11/12/2024 |
2.4.1 | 131 | 11/11/2024 |
2.4.0 | 136 | 11/10/2024 |
2.3.1 | 139 | 11/10/2024 |
2.3.0 | 148 | 11/9/2024 |
2.2.1 | 131 | 11/8/2024 |
2.2.0 | 138 | 11/7/2024 |
2.0.1 | 138 | 11/6/2024 |
2.0.0 | 326 | 7/31/2024 |
1.1.0-beta.1 | 449 | 3/26/2019 |
1.0.0 | 48,820 | 3/26/2019 |
0.1.0-beta.9 | 444 | 2/4/2019 |
0.1.0-beta.8 | 410 | 1/20/2019 |
0.1.0-beta.7 | 410 | 1/17/2019 |
0.1.0-beta.6 | 466 | 1/16/2019 |
0.1.0-beta.4 | 436 | 1/15/2019 |
0.1.0-beta.3 | 424 | 1/15/2019 |
0.1.0-beta.2 | 429 | 1/15/2019 |
0.1.0-beta.1 | 427 | 1/7/2019 |