AlphaCSV 1.0.0-alpha0
See the version list below for details.
dotnet add package AlphaCSV --version 1.0.0-alpha0
NuGet\Install-Package AlphaCSV -Version 1.0.0-alpha0
<PackageReference Include="AlphaCSV" Version="1.0.0-alpha0" />
<PackageVersion Include="AlphaCSV" Version="1.0.0-alpha0" />
<PackageReference Include="AlphaCSV" />
paket add AlphaCSV --version 1.0.0-alpha0
#r "nuget: AlphaCSV, 1.0.0-alpha0"
#:package AlphaCSV@1.0.0-alpha0
#addin nuget:?package=AlphaCSV&version=1.0.0-alpha0&prerelease
#tool nuget:?package=AlphaCSV&version=1.0.0-alpha0&prerelease
AlphaCSV
A small .net 6 library that reads and writes CSV files. The goal of this library is to help anyone who makes small automation or migration projects. It can however be used in larger projects.
The library imports the CSV into a datatable. The columns of the datatable can have multiple types which can be described in a datatable schema.
This library can also parse CSV files into lists of classes or records provided that:
- They provide public parameterless constructors
- Have public set properties
Before Proceeding
This library is released as is and is still in <b>ALPHA</b> state. I am not reponsible for any issues or possible data loss that may occur with the use of this library.
Installation
In order to use the library just install the nuget package from nuget.org.
Usage
Just include the following line in the start of your program or in your global usings.
using AlphaCSV;
Parsing of a simple file
A simple csv file such as the following:
ColumnA,ColumnB
Row1,ValA
Row2,ValB
Row3,ValC
Can be parsed as follows:
CSVParser parser = new CSVParser();
DataTable result = parser.ParseSimpleCSV(filename);
Note: The above method will produce a datatable whose columns will be of string type.
Defining types on the DataTable columns.
Sometimes you may need a more complex file to parse. A file where you might need a
different schema. This function can be performed with the ParseDefinedCSV method.
For example for a file like this:
ColumnA,ColumnB
Row1,1
Row2,3
Row3,5
DataTable schema = new DataTable();
schema.Columns.Add(new DataColumn("ColumnA", typeof(string)));
schema.Columns.Add(new DataColumn("ColumnB", typeof(int)));
CSVParser parser = new CSVParser();
DataTable result = parser.ParseDefinedCSV(schema, filename);
The CSV file is then parsed into a datatable. Note that the schema of the file
has to be defined, both in terms of column names and also in terms of type.
Parsing custom types with the ParseType<T> method.
If you have custom types then those could be parsed as the following example: For a record
public record Person {
public string Name { get; set; }
public string Surname { get; set; }
}
A CSV file could can be parsed as follows:
CSVParser parser = new CSVParser();
List<Person> persons = parser.ParseType<Person>(filepath);
Of course the CSV file should have the following form
Name,Surname
John,Doe
Jane,Doe
The column ordering does not matter as long as the correct property names are given. The following file is just as valid:
Surname,Name
Doe,John
Doe,Jane
The CSVParseOptions Class
This class controls the behavior of the csv parser and may be passed to the parser method as an optional argument.
The options can be set through the public properies of the class. The parameters that can be controlled are the following :
- The
Delimeter. This is the character that seperates the fields within the file. (Default value of,). - The
CommentCharacter. Every line that starts with this character is ignored. (Default value of#). - The
QuoteCharacter. This is the character that escapes a field if that field contains theDelimerercharacter. - The
CheckHeadersindicates to the parser if it must validate the file headers against a schema. (Defaultfalse). This does not apply for theParseTypemethod as it always checks for the correct names. - The
ValidateFieldsindicates to the parser if it must validate the field values against a provided regular expression (Defaultfalse). - The
DateTimeFormatindicates to the parser the format of any DateTime that may be contained in the file. (Default is""). - The
ContainsHeadersindicates if the CSV file has a header row. (Default value isfalse) note that this option is not taken into account when reading a defined CSV. - The
AllowEmptyLastFieldIndicates wether the last field of the file lines can be empty. (eg when there is no data on the last field) Defaulttrue.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- System.IO.Abstractions (>= 16.1.4)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AlphaCSV:
| Package | Downloads |
|---|---|
|
libBOM
A package that handles BOM for internal tooling |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-beta.8 | 37 | 9/12/2026 |
| 1.0.0-beta.7 | 86 | 3/29/2026 |
| 1.0.0-beta.6 | 190 | 6/14/2025 |
| 1.0.0-beta.5 | 134 | 7/10/2024 |
| 1.0.0-beta.4 | 229 | 2/23/2023 |
| 1.0.0-beta.3 | 196 | 2/22/2023 |
| 1.0.0-beta.2 | 210 | 2/22/2023 |
| 1.0.0-beta.1 | 277 | 3/15/2022 |
| 1.0.0-beta.0 | 262 | 3/15/2022 |
| 1.0.0-alpha0 | 276 | 1/30/2022 |