GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bytecode-api/BytecodeApi.CsvParser at master · bytecode77/bytecode-api

Expand file tree

/

BytecodeApi.CsvParser

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

BytecodeApi.CsvParser

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
.nuget
.nuget
 
 
Properties
Properties
 
 
BytecodeApi.CsvParser.csproj
BytecodeApi.CsvParser.csproj
 
 
CsvCell.cs
CsvCell.cs
 
 
CsvDelimiterDetector.cs
CsvDelimiterDetector.cs
 
 
CsvFile.cs
CsvFile.cs
 
 
CsvHelper.cs
CsvHelper.cs
 
 
CsvIterator.cs
CsvIterator.cs
 
 
CsvRow.cs
CsvRow.cs
 
 
CsvRowCollection.cs
CsvRowCollection.cs
 
 
README.md
README.md
 
 

README.md

Outline

BytecodeApi.CsvParser

Library for CSV parsing and writing.

Examples

BytecodeApi.CsvParser

CsvFile

The CsvFile class can read and write CSV files:

CsvFile csv = CsvFile.FromFile(@"A:\path\to\file.csv", hasHeaderRow: true, delimiter: ";");

if (csv.HasErrors)
{
	Console.WriteLine("There were parsing errors.");
}

if (!csv.IsColumnCountConsistent)
{
	Console.WriteLine("Not all rows have the same amount of columns.");
}

// The headers. This value is null, if hasHeaderRow is set to false.
string[]? headers = csv.Headers;

foreach (CsvRow row in csv.Rows)
{
	foreach (CsvCell cell in row)
	{
		Console.WriteLine(cell.Value);
	}
}

To auto detect the delimiter, simply pass null:

CsvFile csv = CsvFile.FromFile(@"A:\path\to\file.csv", hasHeaderRow: true, delimiter: null);

After modifying the CsvFile object, it can be written:

csv.Save(@"A:\path\to\file.csv", alwaysQuote: false);
CsvIterator

Sometimes, parsing extremely large CSV files is a requirement. The CsvIterator provides streaming capabilities:

The iterator can also detect the delimiter, if the delimiter parameter is not provided:

IEnumerable<CsvRow> iterator = CsvIterator.FromFile(@"A:\path\to\file.csv");

foreach (CsvRow row in iterator)
{
	// ...
}

And to stream an IEnumerable<CsvRow> back, use ToFile or ToStream:

CsvIterator.ToFile(@"A:\path\to\file.csv", GetRows(), ";");

IEnumerable<CsvRow> GetRows()
{
	yield return new CsvRow("col1", "col2", "col3");
	// ...
}

Changelog

5.0.0 (15.02.2026)

  • change: Targeting .NET 10.0

4.0.0 (15.09.2025)

  • change: Targeting .NET 9.0
  • new: byte[] CsvFile.Save() method overload

3.0.0 (08.09.2023)

  • Initial release
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.