Git Product home page Git Product logo

skybrud.csv's Introduction

Skybrud.Csv

Skybrud.Csv is a small library for parsing and generating CSV files. It's written in .NET, and supports both .NET Standard 1.3 and .NET Framework 4.5 (and newer).

Installation

To install the package, pick one of the two methods below:

  1. NuGet Package
    Install this NuGet package in your Visual Studio project. Makes updating easy.

  2. ZIP file
    Grab a ZIP file of the latest release; unzip and move the Skybrud.Csv.dll for your target framework to the bin directory of your project.

Usage

Generate and save a new CSV file using method chaining:

CsvFile csv1 = new CsvFile()
    .AddColumn("Id")
    .AddColumn("Name")
    .AddColumn("Description")
    .AddRow()
        .AddCell("1234")
        .AddCell("Hej med\ndig")
        .AddCell("hello \"world\"")
    .AddRow()
        .AddCell("5678")
        .AddCell("rød grød med fløde")
        .AddCell("hello")
    .File
    .Save("C:/Example.csv", CsvSeparator.Tab, Encoding.UTF8);

Load a CSV file from disk:

// Load the file from disk (assuming tabular as separator and UTF-8 as encoding)
CsvFile csv2 = CsvFile.Load("C:/Example.csv", CsvSeparator.Tab, Encoding.UTF8);

// Iterate through the columns
foreach (CsvColumn column in csv2.Columns)
{
    Console.WriteLine(column.Index + ". " + column.Name);
}

// Iterate through the rows
foreach (CsvRow row in csv2.Rows)
{
    
    Console.WriteLine("Row #" + (row.Index + 1));
    
    // Iterate throug the cells of the row
    foreach (CsvCell cell in row.Cells)
    {
        Console.WriteLine(cell.Column.Name + " => " + cell.Value);
    }

}

skybrud.csv's People

Contributors

abjerner avatar greystate avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

greystate

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.