RawCSV 1.0.0
dotnet add package RawCSV --version 1.0.0
NuGet\Install-Package RawCSV -Version 1.0.0
<PackageReference Include="RawCSV" Version="1.0.0" />
<PackageVersion Include="RawCSV" Version="1.0.0" />
<PackageReference Include="RawCSV" />
paket add RawCSV --version 1.0.0
#r "nuget: RawCSV, 1.0.0"
#:package RawCSV@1.0.0
#addin nuget:?package=RawCSV&version=1.0.0
#tool nuget:?package=RawCSV&version=1.0.0
RawCSV
I was inspired by an example of the smallest CSV parser... And I wondered if it could be even smaller while still maintaining user-friendliness and remaining a NuGet package. In the end, I managed to get it down to 83 lines of code, provided that it
- RFC4180 format
- A user-friendly API for library users
- Support for any Unicode, emojis, and hieroglyphs
- Support for legacy and local encodings
- All types of line breaks
- Nested multi-line texts
Example of use
when you need to get the data as quickly and easily as possible
using RawCSV;
using System.IO;
// parse a csv file
byte[] fileBytes = File.ReadAllBytes("data.csv");
string[][] rows = csv.parse(fileBytes);
// work with the data
foreach (var row in rows) {
Console.WriteLine($"Name: {row[0]}, Email: {row[1]}");
}
// write it back to bytes
byte[] newCsvBytes = csv.write(rows);
You may also need a lower API level without unnecessary memory allocations, so here is an example below
using RawCSV;
using System;
using System.IO;
byte[] fileBytes = File.ReadAllBytes("huge_data.csv");
var parser = new csv_parser(fileBytes);
// the loop runs over the file, outputting ranges of fields
while (parser.next(out Range fieldIndices) != 0)
{
// access the field directly from the original buffer
ReadOnlySpan<byte> field = fileBytes.AsSpan(fieldIndices);
// process your bytes instantly...
}
Content
Install
Install via NuGet or:
dotnet add package RawCSV
Performance
Benchmark results on an Intel Core i5-8600 CPU running .NET 8.0.
| Method | Mean | Speed | Allocated |
|---|---|---|---|
raw: 10k plain |
1.306 ms | ~275 MB/s | 0 B |
raw: 10k quoted |
1.071 ms | ~298 MB/s | 0 B |
raw: worldcities (150MB) |
610.73 ms | ~248 MB/s | 0 B |
api: parse 10k plain |
6.614 ms | ~54 MB/s | 2,912 KB |
api: write 10k rows |
2.603 ms | ~138 MB/s | 3,564 KB |
| 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 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. |
-
net8.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.0 | 51 | 5/9/2026 |