CSVToolsSharp 1.0.5

dotnet add package CSVToolsSharp --version 1.0.5
                    
NuGet\Install-Package CSVToolsSharp -Version 1.0.5
                    
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="CSVToolsSharp" Version="1.0.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CSVToolsSharp" Version="1.0.5" />
                    
Directory.Packages.props
<PackageReference Include="CSVToolsSharp" />
                    
Project file
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 CSVToolsSharp --version 1.0.5
                    
#r "nuget: CSVToolsSharp, 1.0.5"
                    
#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 CSVToolsSharp@1.0.5
                    
#: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=CSVToolsSharp&version=1.0.5
                    
Install as a Cake Addin
#tool nuget:?package=CSVToolsSharp&version=1.0.5
                    
Install as a Cake Tool

<p align="center"> <img src="https://github.com/kris701/CSVToolsSharp/assets/22596587/9251d9de-632b-41c5-a1da-31750cd24384" width="200" height="200" /> </p>

Build and Publish Nuget Nuget GitHub last commit (branch) GitHub commit activity (branch) Static Badge Static Badge Static Badge

CSV Tools Sharp is a little project to manipulate and output CSV files. You can find it on the NuGet Package Manager or the GitHub Package Manager.

How to Use

The package is inspired by that of System.Text.Json, where you can access two primary static methods, CSVSerialiser.Deserialise and CSVSerialiser.Serialise to convert generic classes into CSV format and back. You have to give the properties of the CSV serialisable classes a CSVColumn attribute for them to be targeted for serialisation. You can also pass a CSVSerialiserOptions object to the serialisation/deserialisation for more settings.

If you dont want to use this statically typed serialisation and deserialisation, there is also a DynamicCSV class. This is intended for times you dont have a class structure or just want a more "direct" way of making CSV files. In it you can add and remove columns, rows, cells, etc at will.

Example

Class to serialise/deserialize:

public class TestClass
{
    [CSVColumn("Column1")]
    public string Value { get; set; }
}

You can then use the serialiser and deserialiser as follows:

var csvText = CSVSerialiser.Serialise(new List<TestClass>(){ new TestClass(){ Value = "abc" } });

Gives

Column1
abc

Example

Class to serialise/deserialize:

public class TestClass2
{
    [CSVColumn("Column1")]
    public string Value { get; set; }
    [CSVColumn("Column 2")]
    public string Value2 { get; set; }
}

You can also make the CSV print more readably:

var csvText = CSVSerialiser.Serialise(
    new List<TestClass2>(){ 
        new TestClass2(){ Value = "asdafaseasasd", Value2 = "abc" } 
    }, new CSVSerialiserOptions(){ PrettyOutput = true });

Gives

Column1      ,Column 2
asdafaseasasd,abc

Example

An example of how to use the DynamicCSV object:

var item = new DynamicCSV(new Dictionary<string, List<string>>());
item.AddColumn("some-column");
item.Insert("some-column", 0, "abc");
item.Insert("some-column", 2, "123");
var csvText = CSVSerialiser.Serialise(item);

Gives the CSV output:

some-column
abc

123
Product 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

    • 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.5 221 3/31/2024
1.0.4 151 3/27/2024
1.0.3 196 3/26/2024
1.0.2 189 3/21/2024
1.0.1 179 3/21/2024
1.0.0 160 3/21/2024