CSVToolsSharp 1.0.5
dotnet add package CSVToolsSharp --version 1.0.5
NuGet\Install-Package CSVToolsSharp -Version 1.0.5
<PackageReference Include="CSVToolsSharp" Version="1.0.5" />
<PackageVersion Include="CSVToolsSharp" Version="1.0.5" />
<PackageReference Include="CSVToolsSharp" />
paket add CSVToolsSharp --version 1.0.5
#r "nuget: CSVToolsSharp, 1.0.5"
#:package CSVToolsSharp@1.0.5
#addin nuget:?package=CSVToolsSharp&version=1.0.5
#tool nuget:?package=CSVToolsSharp&version=1.0.5
<p align="center"> <img src="https://github.com/kris701/CSVToolsSharp/assets/22596587/9251d9de-632b-41c5-a1da-31750cd24384" width="200" height="200" /> </p>
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 | 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. |
-
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.