Dameng.SepEx
0.2.2
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Dameng.SepEx --version 0.2.2
NuGet\Install-Package Dameng.SepEx -Version 0.2.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dameng.SepEx" Version="0.2.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dameng.SepEx" Version="0.2.2" />
<PackageReference Include="Dameng.SepEx" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dameng.SepEx --version 0.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Dameng.SepEx, 0.2.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Dameng.SepEx@0.2.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dameng.SepEx&version=0.2.2
#tool nuget:?package=Dameng.SepEx&version=0.2.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Dameng.SepEx
A high-performance 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.
Features
- Source Generator: Automatically generates type-safe CSV readers and writers at compile time
- High Performance: Built on top of the fast Sep library
- Attribute-Based Configuration: Use attributes to configure column mapping, formatting, and behavior
- Flexible Column Mapping: Support for column names, indexes, default values, and formatting
- Type Safety: Compile-time type checking and IntelliSense support
Installation
Install the NuGet packages:
dotnet add package Dameng.SepEx
dotnet add package Dameng.SepEx.Generator
Quick Start
- Define your data model with attributes:
[GenSepParsable]
public partial class Person
{
[SepColumnIndex(0)]
public string Name { get; set; }
[SepColumnName("Age")]
public int Age { get; set; }
[SepDefaultValue("Unknown")]
public string City { get; set; }
[SepIgnore]
public string InternalId { get; set; }
}
- Read and write CSV data:
// Reading
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
var people = new List<Person> { /* ... */ };
using var writer = Sep.Writer().ToFile("output.csv");
writer.WriteRecord(people);
External Data Model
- Generate type info using attributes:
[GenSepTypeInfo<Person>()]
public partial class PersonTypeInfo;
- Read and write CSV data:
// Reading
using var reader = Sep.Reader().FromFile("people.csv");
foreach (var person in reader.GetRecords<Person>(PersonTypeInfo.Person))
{
Console.WriteLine($"{person.Name} is {person.Age} years old");
}
// Writing
var people = new List<Person> { /* ... */ };
using var writer = Sep.Writer().ToFile("output.csv");
writer.WriteRecord(people, PersonTypeInfo.Person);
Available Attributes
[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 values
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Sep (>= 0.11.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.