
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
NitroTextFieldParser
Advanced tools
The NitroTextFieldParser is a blazing-fast .NET library for parsing delimited or fixed-width text files. Built for high performance, it minimizes memory usage by leveraging ReadOnlyMemory<char>
and supports advanced features such as quoted field handling. Whether you're processing CSVs or custom delimited files, NitroTextFieldParser provides robust and efficient parsing.
The NitroTextFieldParser outperforms the built-in TextFieldParser
in terms of speed and memory usage. The following benchmark results demonstrate the performance benefits of using the NitroTextFieldParser when processing 1000Rows x 9Columns CSV data:
Method | Mean | Error | StdDev | Rank | Gen0 | Gen1 | Gen2 | Allocated |
---|---|---|---|---|---|---|---|---|
NitroTextFieldParser | 1.663 ms | 0.0187 ms | 0.0175 ms | 1 | 306.6406 | 134.7656 | - | 1.35 MB |
OldTextFieldParser | 9.543 ms | 0.1640 ms | 0.1534 ms | 2 | 3343.7500 | 421.8750 | 15.6250 | 12.51 MB |
Stream
, suitable for large files.Include the NitroTextFieldParser
class in your .NET project or package it into a shared library.
Create an instance of the parser with your data stream.
using NitroTextFieldParser;
using (var stream = File.OpenRead("data.csv"))
using (var parser = new TextFieldParser(stream))
{
parser.SetDelimiters(","); // Set the delimiter for parsing
parser.HasFieldsEnclosedInQuotes = true; // Enable quote handling
}
Define the delimiters used to separate fields:
parser.SetDelimiters(",", "\t"); // Supports multiple delimiters
Read and parse fields line by line:
while (!parser.EndOfData)
{
var fields = parser.ReadFields(); // Returns ReadOnlyMemory<char>[] for efficient access
foreach (var field in fields)
{
Console.WriteLine(field.ToString()); // Convert to string for display
}
}
Enable quote handling for fields:
parser.HasFieldsEnclosedInQuotes = true; // Enable quote handling
Example Input:
"Name","Age","City"
"Alice, Bob","30","New York"
Output:
Row 1:
Row 2:
Specify a custom character encoding:
using (var parser = new TextFieldParser(stream, Encoding.UTF8))
{
// Custom encoding setup
}
Keep the stream open after parsing:
var parser = new TextFieldParser(stream, Encoding.UTF8, true, true);
Read the entire file content at once:
var content = parser.ReadToEnd();
Input File (data.csv):
"ID","Name","Email"
1,"John Doe","john@example.com"
2,"Jane Smith","jane@example.com"
Output:
Row 1:
Row 2:
Row 3:
This software is dual-licensed:
Custom Open Source License You may use this software under the terms of this Custom Open Source License.
Commercial License For commercial use, a separate license is required. Please contact stianbekker@gmail.com for details.
Copyright (c) [2025] [Christiaan Bekker/Stikie123]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to use, copy, modify, merge, and distribute the Software, subject to the following conditions:
The Software may be used freely in:
For any commercial use, including but not limited to using the Software in paid products, services, or proprietary projects, the user must obtain a separate commercial license from [Christiaan Bekker/Stikie123]. Please contact [stianbekker@gmail.com] to arrange licensing terms.
Credit must be given to [Christiaan Bekker/Stikie123] in all copies or substantial portions of the Software. This includes clear attribution in the documentation, source code, or any materials distributed with the Software.
Any modifications made to the Software must:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For commercial use, please acquire a license by contacting [stianbekker@gmail.com].
FAQs
Super fast, memory efficient parser
We found that nitrotextfieldparser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.