CSVNetCore 1.0.0
dotnet add package CSVNetCore --version 1.0.0
NuGet\Install-Package CSVNetCore -Version 1.0.0
<PackageReference Include="CSVNetCore" Version="1.0.0" />
paket add CSVNetCore --version 1.0.0
#r "nuget: CSVNetCore, 1.0.0"
// Install CSVNetCore as a Cake Addin #addin nuget:?package=CSVNetCore&version=1.0.0 // Install CSVNetCore as a Cake Tool #tool nuget:?package=CSVNetCore&version=1.0.0
CSV.Net
CSV.Net is a flexible and easy-to-use library for serializing and deserializing objects to and from CSV files. It leverages reflection to map CSV columns to object properties and supports custom formatting for numeric types based on culture-specific settings.
Features
- Serialize and deserialize objects to/from CSV.
- Support for custom column names using
CsvColumnAttribute
. - Handles various numeric types (
float
,double
,decimal
) with custom formatting. - Configurable delimiter for CSV files (default is
;
). - Error handling during serialization and deserialization.
- Supports both CSV files with and without headers.
- Supports automatic mapping of CSV columns to object properties using reflection.
Installation
To use CSV.Net in your project, you can either clone this repository or add it as a dependency in your .csproj
file.
Clone the repository:
git clone https://github.com/Andy16823/CSV.Net.git
Add the library as a dependency (if you're using it as a package):
If you publish it as a NuGet package, you can install it via NuGet:
dotnet add package CSV.Net
Usage
Serializing Objects to CSV
using CSVNet;
var personList = new List<Person>
{
new Person { FirstName = "Markus", LastName = "Mustermann", Age = 30, Salary = 1200.50f },
new Person { FirstName = "Nadine", LastName = "Musterfrau", Age = 32, Salary = 1500.75f }
};
string filePath = "output.csv";
Converter.Serialize(personList, filePath);
Deserializing CSV to Objects
using CSVNet;
string filePath = "input.csv";
var deserializedList = Converter.Deserialize<Person>(filePath);
Defining Object Properties for CSV
You can use the CsvColumnAttribute
to specify how object properties should be mapped to CSV columns:
public class Person
{
[CsvColumn("First Name")]
public string FirstName { get; set; }
[CsvColumn("Last Name")]
public string LastName { get; set; }
[CsvColumn("Age")]
public int Age { get; set; }
[CsvColumn("Salary")]
public float Salary { get; set; }
}
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
- Fork the repository.
- Create your feature branch (
git checkout -b feature/my-new-feature
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature/my-new-feature
). - Open 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. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 83 | 12/8/2024 |