![]() |
VOOZH | about |
dotnet add package Dameng.SepEx --version 0.3.1
NuGet\Install-Package Dameng.SepEx -Version 0.3.1
<PackageReference Include="Dameng.SepEx" Version="0.3.1" />
<PackageVersion Include="Dameng.SepEx" Version="0.3.1" />Directory.Packages.props
<PackageReference Include="Dameng.SepEx" />Project file
paket add Dameng.SepEx --version 0.3.1
#r "nuget: Dameng.SepEx, 0.3.1"
#:package Dameng.SepEx@0.3.1
#addin nuget:?package=Dameng.SepEx&version=0.3.1Install as a Cake Addin
#tool nuget:?package=Dameng.SepEx&version=0.3.1Install as a Cake Tool
A high-performance, Native AOT compatible source generator for working with separated values (CSV/TSV) files in C#. This library extends the excellent Sep library by providing compile-time code generation for strongly-typed reading and writing of CSV data.
Perfect for developers migrating from CSVHelper who need Native AOT support or want better performance through source generation.
Install the NuGet packages:
dotnet add package Dameng.SepEx
Define your data model as a partial class with [GenSepParsable] and use attributes to configure column mapping:
[GenSepParsable]
public partial class Person
{
[SepColumnName("FullName")]
[SepColumnIndex(0)]
public string Name { get; set; }
[SepColumnName("Age")]
public int Age { get; set; }
[SepDefaultValue("Unknown")]
public string City { get; set; }
[SepColumnIgnore]
public string InternalId { get; set; }
}
// Reading CSV
using var reader = Sep.Reader().FromFile("people.csv");
foreach (var person in reader.GetRecords<Person>())
{
Console.WriteLine($"{person.Name} is {person.Age} years old");
}
// Writing CSV
var people = new List<Person> { /* ... */ };
using var writer = Sep.Writer().ToFile("output.csv");
writer.WriteRecords(people);
If you're migrating from CSVHelper, simply update your attributes and make classes partial:
| CSVHelper | Dameng.SepEx |
|---|---|
[Name("column")] |
[SepColumnName("column")] |
[Index(0)] |
[SepColumnIndex(0)] |
[Ignore] |
[SepColumnIgnore] |
[Default("value")] |
[SepDefaultValue("value")] |
[Format("format")] |
[SepColumnFormat("format")] |
Key changes:
[GenSepParsable] attribute and make class partialSep.Reader() and Sep.Writer() instead of CSVHelper APIsFor classes you can't modify (e.g., from external libraries), use type info generation:
[GenSepTypeInfo<ExternalPerson>()]
public partial class ExternalPersonTypeInfo;
// Usage
using var reader = Sep.Reader().FromFile("people.csv");
foreach (var person in reader.GetRecords<ExternalPerson>(ExternalPersonTypeInfo.ExternalPerson))
{
// Process person
}
[GenSepTypeInfo<T>()]: Generate type info for the specified type[SepColumnName(string name)]: Specify column name[SepColumnIndex(int index)]: Specify column index for reading/writing order[SepDefaultValue(object value)]: Set default value when column is missing[SepColumnIgnore]: Ignore property/field during CSV operations[SepColumnFormat(string format)]: Specify format for writing valuesThis project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.