All Projects → TinyCsvParser → Tinycsvparser

TinyCsvParser / Tinycsvparser

Licence: mit
Easy to use, easy to extend and high-performance library for CSV parsing with .NET

Projects that are alternatives of or similar to Tinycsvparser

Clevercsv
CleverCSV is a Python package for handling messy CSV files. It provides a drop-in replacement for the builtin CSV module with improved dialect detection, and comes with a handy command line application for working with CSV files.
Stars: ✭ 887 (+259.11%)
Mutual labels:  csv-parser
Csv Stream
📃 Streaming CSV Parser for Node. Small and made entirely out of streams.
Stars: ✭ 98 (-60.32%)
Mutual labels:  csv-parser
Csv2
Fast CSV parser and writer for Modern C++
Stars: ✭ 164 (-33.6%)
Mutual labels:  csv-parser
Faster Than Csv
Faster CSV on Python 3
Stars: ✭ 52 (-78.95%)
Mutual labels:  csv-parser
Ngx Papaparse
Papa Parse wrapper for Angular
Stars: ✭ 83 (-66.4%)
Mutual labels:  csv-parser
React Papaparse
react-papaparse is the fastest in-browser CSV (or delimited text) parser for React. It is full of useful features such as CSVReader, CSVDownloader, readString, jsonToCSV, readRemoteFile, ... etc.
Stars: ✭ 116 (-53.04%)
Mutual labels:  csv-parser
Csvutil
csvutil provides fast and idiomatic mapping between CSV and Go (golang) values.
Stars: ✭ 501 (+102.83%)
Mutual labels:  csv-parser
Codablecsv
Read and write CSV files row-by-row or through Swift's Codable interface.
Stars: ✭ 214 (-13.36%)
Mutual labels:  csv-parser
Csv Parser
Fast, header-only, extensively tested, C++11 CSV parser
Stars: ✭ 90 (-63.56%)
Mutual labels:  csv-parser
React Csv Reader
React component that handles csv file input and its parsing
Stars: ✭ 138 (-44.13%)
Mutual labels:  csv-parser
Csv
Fast C# CSV parser
Stars: ✭ 53 (-78.54%)
Mutual labels:  csv-parser
Csvparser
A swift package for read and write CSV file
Stars: ✭ 73 (-70.45%)
Mutual labels:  csv-parser
Etl.net
Mass processing data with a complete ETL for .net developers
Stars: ✭ 129 (-47.77%)
Mutual labels:  csv-parser
Fast Csv
CSV parser and formatter for node
Stars: ✭ 1,054 (+326.72%)
Mutual labels:  csv-parser
Cassava
A CSV parsing and encoding library optimized for ease of use and high performance
Stars: ✭ 193 (-21.86%)
Mutual labels:  csv-parser
Filehelpers
The FileHelpers are a free and easy to use .NET library to read/write data from fixed length or delimited records in files, strings or streams
Stars: ✭ 917 (+271.26%)
Mutual labels:  csv-parser
Papaparse
Fast and powerful CSV (delimited text) parser that gracefully handles large files and malformed input
Stars: ✭ 10,206 (+4031.98%)
Mutual labels:  csv-parser
Csv
[DEPRECATED] See https://github.com/p-ranav/csv2
Stars: ✭ 237 (-4.05%)
Mutual labels:  csv-parser
Intellij Csv Validator
CSV validator, highlighter and formatter plugin for JetBrains Intellij IDEA, PyCharm, WebStorm, ...
Stars: ✭ 198 (-19.84%)
Mutual labels:  csv-parser
Dataclass Csv
Map CSV to Data Classes
Stars: ✭ 133 (-46.15%)
Mutual labels:  csv-parser

TinyCsvParser

TinyCsvParser is a .NET library to parse CSV data in an easy and fun way, while offering very high performance and a very clean API. It is highly configurable to provide maximum flexibility.

To get started quickly, follow the Quickstart.

TinyCsvParser supports .NET Core.

Installing TinyCsvParser

You can use NuGet to install TinyCsvParser. Run the following command in the Package Manager Console.

PM> Install-Package TinyCsvParser

Documentation and Changelog

TinyCsvParser comes with an official documentation and changelog:

Basic Usage

This is only an example for the most common use of TinyCsvParser. For more detailed information on custom formats and more advanced use-cases, please consult the full User Guide of the official documentation.

Imagine we have list of Persons in a CSV file persons.csv with their first name, last name and birthdate.

FirstName;LastName;BirthDate
Philipp;Wagner;1986/05/12
Max;Musterman;2014/01/02

The corresponding domain model in our system might look like this.

private class Person
{
    public string FirstName { get; set; }
    
    public string LastName { get; set; }
    
    public DateTime BirthDate { get; set; }
}

When using TinyCsvParser you have to define the mapping between the columns in the CSV data and the property in you domain model.

private class CsvPersonMapping : CsvMapping<Person>
{
    public CsvPersonMapping()
        : base()
    {
        MapProperty(0, x => x.FirstName);
        MapProperty(1, x => x.LastName);
        MapProperty(2, x => x.BirthDate);
    }
}

And then we can use the mapping to parse the CSV data with a CsvParser.

namespace TinyCsvParser.Test
{
    [TestFixture]
    public class TinyCsvParserTest
    {
        [Test]
        public void TinyCsvTest()
        {
            CsvParserOptions csvParserOptions = new CsvParserOptions(true, ';');
            CsvPersonMapping csvMapper = new CsvPersonMapping();
            CsvParser<Person> csvParser = new CsvParser<Person>(csvParserOptions, csvMapper);

            var result = csvParser
                .ReadFromFile(@"persons.csv", Encoding.ASCII)
                .ToList();

            Assert.AreEqual(2, result.Count);

            Assert.IsTrue(result.All(x => x.IsValid));
			
            Assert.AreEqual("Philipp", result[0].Result.FirstName);
            Assert.AreEqual("Wagner", result[0].Result.LastName);

            Assert.AreEqual(1986, result[0].Result.BirthDate.Year);
            Assert.AreEqual(5, result[0].Result.BirthDate.Month);
            Assert.AreEqual(12, result[0].Result.BirthDate.Day);

            Assert.AreEqual("Max", result[1].Result.FirstName);
            Assert.AreEqual("Mustermann", result[1].Result.LastName);

            Assert.AreEqual(2014, result[1].Result.BirthDate.Year);
            Assert.AreEqual(1, result[1].Result.BirthDate.Month);
            Assert.AreEqual(1, result[1].Result.BirthDate.Day);
        }
    }
}

License

The library is released under terms of the MIT License:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].