Giter Site home page Giter Site logo

cesil's Introduction

Cesil

Modern CSV (De)Serializer

Run Tests (Debug) Line Coverage Branch Coverage

PRE-RELEASE

This code hasn't seen much production use, please use with caution and report any issues you encounter.

Documentation

Consult The Wiki™ for documentation, and Cesil's Github Pages for references.

You may be interested in:

Quick Start

  1. Install the latest Cesil off of Nuget.
  2. Add using Cesil; to your C# file
  3. Create a configuration (with default Options) with either Configuration.For<TYourType>() or Configuration.ForDynamic(), as appropriate for your use case
  4. Create a reader or writer using one of the CreateReader, CreateAsyncReader, CreateWriter, or CreateAsyncWriter methods on the configuration.
    • Each of these methods has a number of overloads, supporting using TextReaders, Pipes, and so on.
  5. Use the methods on the IReader<TRow>, IAsyncReader<TRow>, IWriter<TRow>, or IAsyncWriter<TRow> interface to read or write your data.

Example: Reading Synchronously

Using a convient method:

using Cesil;

// ...

IEnumerable<MyType> rows = CesilUtils.Enumerate<MyType>(/*Some TextReader*/);

In a more explicit, and configurable, way using explicit configuration and options.

using Cesil;

// ...

Options myOptions = /* ... */
IBoundConfiguration<MyType> myConfig = Configuration.For<MyType>(myOptions);

using(TextReader reader = /* ... */)
using(IReader<MyType> csv = myConfig.CreateReader(reader))
{
    IEnumerable<MyType> rows = csv.EnumerateAll();
}

For more detail, see Reading.

Example: Reading Asynchronously

Using a convient method:

using Cesil;

// ...

IAsyncEnumerable<MyType> rows = CesilUtils.EnumerateAsync<MyType>(/*Some TextReader*/);

In a more explicit, and configurable, way using explicit configuration and options.

using Cesil;

// ...

Options myOptions = /* ... */
IBoundConfiguration<MyType> myConfig = Configuration.For<MyType>(myOptions);

using(TextReader reader = /* ... */)
await using(IAsyncReader<MyType> csv = myConfig.CreateAsyncReader(reader))
{
    IAsyncReader<MyType> rows = csv.EnumerateAllAsync();
}

For more detail, see Reading.

Example: Writing Synchronously

Using a convient method:

using Cesil;

// ...

IEnumerable<MyType> myRows = /* ... */

using(TextWriter writer = /* .. */)
{
    CesilUtilities.Write(myRows, writer);
}

In a more explicit, and configurable, way using explicit configuration and options.

using Cesil;

// ...

IEnumerable<MyType> myRows = /* ... */

Options myOptions = /* ... */
IBoundConfiguration<MyType> myConfig = Configuration.For<MyType>(myOptions);

using(TextWriter writer = /* ... */)
using(IWriter<MyType> csv = myConfig.CreateWriter(writer))
{
    csv.WriteAll(myRows);
}

For more detail, see Writing.

Example: Writing Asynchronously

Using a convient method:

using Cesil;

// ...

// IAsyncEnumerable<MyType> will also work
IEnumerable<MyType> myRows = /* ... */

using(TextWriter writer = /* .. */)
{
    await CesilUtilities.WriteAsync(myRows, writer);
}

In a more explicit, and configurable, way using explicit configuration and options.

using Cesil;

// ...

// IAsyncEnumerable<MyType> will also work
IEnumerable<MyType> myRows = /* ... */

Options myOptions = /* ... */
IBoundConfiguration<MyType> myConfig = Configuration.For<MyType>(myOptions);

using(TextWriter writer = /* ... */)
await using(IWriter<MyType> csv = myConfig.CreateAsyncWriter(writer))
{
    await csv.WriteAllAsync(myRows);
}

For more detail, see Writing.

cesil's People

Contributors

kevin-montrose avatar siliconrob avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.