PutridParrot.Delimited.Data 0.6.0-alpha

This is a prerelease version of PutridParrot.Delimited.Data.
dotnet add package PutridParrot.Delimited.Data --version 0.6.0-alpha
NuGet\Install-Package PutridParrot.Delimited.Data -Version 0.6.0-alpha
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="PutridParrot.Delimited.Data" Version="0.6.0-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PutridParrot.Delimited.Data --version 0.6.0-alpha
#r "nuget: PutridParrot.Delimited.Data, 0.6.0-alpha"
#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.
// Install PutridParrot.Delimited.Data as a Cake Addin
#addin nuget:?package=PutridParrot.Delimited.Data&version=0.6.0-alpha&prerelease

// Install PutridParrot.Delimited.Data as a Cake Tool
#tool nuget:?package=PutridParrot.Delimited.Data&version=0.6.0-alpha&prerelease

Delimited.Data

Build NuGet version (PutridParrot.Delimited.Data) GitHub license GitHub Releases GitHub Issues

Delimited.Data was designed to allow the user to interact CSV, TSV etc. data.

Everything happens within the Delimited.Data.Specializations assembly, but we have wrapper specializations for Csv and Tsv which you can easily use or create your own on top of the Delimited.Data class.

Let's start by looking at the most obvious of the specializations - those which interact with CSV.

We have several ways of dealing with the parsing of delimited data, from a low level reader to a version which serializes/deserializes to objects and finally a dynamic way of using CSV which allows me to use LINQ to make the CSV querable.

CsvReader/CsvWriter

Inheriting from the DelimitedStreamReader/DelimitedStreamWriter these offer basic functionality allowing you to read a line of delimited data at a time or writing a line at a time. These classes will parse the data and return an IList of string items, in the case of the reader. The writer takes an IEnumerable of strings and writes them in the format of the delimited data. In this case reading and writing CSV.

var reader = new CsvReader(stream);

IList<string> fields;
while((fields = reader.ReadLine()) != null)

{ 
   // do something with the fields
}

CsvSerializer

This is a convenience class for using the DelimitedSerializer. The CsvSerializer can serialize/deserialize objects to/from the data. It can use either attributes on the serializable object or can be supplied with "mappings" which tell it what to map from/to.

CsvEnumerator

The next method of working with delimited data is the DelimitedDataEnumerator. The Csv specialization again , is just a convenience for working with the Csv data options.

This method of interacting with delimited data will only deserialize data and instead of to an IList or a pre-defined object, it will return dynamic data. This allows us to interact with the field names via a couple of mechanism. The first are based upon using the heading name from the data the second via the column index.

The resultant IEnumerable is also useable from LINQ thus allowing us to query the data.

Code Generation

In some cases we need to create an object or it's mappings (for use with the CsvSerializer) from the data. To save having to write the code for this we can use the DelimitedCodeGenerator application to generate the .cs file representing the serialization object.

Changes

  • 0.5.0.0 - Consolidated code into a single DLL
  • 0.6.0.0 - Add Async Read/Write methods. Removed DelimitedStreamConnector due to new more useful implementation being built, also started to add nullable parameters.

Library license

The library is available under the MIT license. See the License file in the GitHub repository.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.6.0-alpha 79 6/3/2023
0.5.0-alpha 69 5/30/2023
0.4.0-alpha 67 5/30/2023
0.3.0-alpha 87 3/2/2023
0.2.0-alpha 86 2/20/2023