Csv
Fast C# CSV parser
Install / Use
/learn @nreco/CsvREADME
NReco.Csv
Ultra-fast C# CSV parser: implements stream reader and writer.
- very fast: x2-x4 times faster than JoshClose's CSVHelper
- memory efficient: uses only single circular buffer, no allocations in heap for CSV of any size
- lightweight: bare csv parser with simple API
- tolerant to not-fully correct CSV files, you can control max length of CSV file (useful for processing end-user CSV uploads)
- can be used for stream processing of many-GB CSV files
- supports all .NET versions: Framework 4.5+, .NET Core, NET6+
How to use
Parse CSV stream:
using (var streamRdr = new StreamReader(inputStream)) {
var csvReader = new CsvReader(streamRdr, ",");
while (csvReader.Read()) {
for (int i=0; i<csvReader.FieldsCount; i++) {
string val = csvReader[i];
}
}
}
Generate CSV to stream:
using (var streamWr = new StreamWriter(outputStream)) {
var csvWriter = new CsvWriter(streamWr);
// write line
csvWriter.WriteField("Value with double quote\"");
csvWriter.WriteField("And with\nnew line");
csvWriter.WriteField("Normal");
csvWriter.NextRecord();
}
Who is using this?
NReco.Csv is in production use at SeekTable.com and PivotData microservice.
License
Copyright 2017-2024 Vitaliy Fedorchenko and contributors
Distributed under the MIT license
Related Skills
node-connect
333.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
333.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
82.0kCommit, push, and open a PR
