SimpleCsvParser.Core 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleCsvParser.Core --version 1.1.0
NuGet\Install-Package SimpleCsvParser.Core -Version 1.1.0
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="SimpleCsvParser.Core" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleCsvParser.Core --version 1.1.0
#r "nuget: SimpleCsvParser.Core, 1.1.0"
#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 SimpleCsvParser.Core as a Cake Addin
#addin nuget:?package=SimpleCsvParser.Core&version=1.1.0

// Install SimpleCsvParser.Core as a Cake Tool
#tool nuget:?package=SimpleCsvParser.Core&version=1.1.0

Simple Csv Parser

A csv parser that is meant to convert csv files into lists of objects.

Features

  • Delimited file parsing
  • Conversion into usable C# objects
  • Binding to headers
  • Large file processing

Installation

Package Manager
    Install-Package SimpleCsvParser.Core
.NET CLI
    dotnet add package SimpleCsvParser.Core
Paket CLI
    paket add SimpleCsvParser.Core

Options

Delimiter *(char) = ','

The delimiter the parser should use for each row in the file

Wrapper *(char) = '"'

The wrapper tag that is used if the delimiter exists in the data of the column

AllowDefaults *(bool) = true

Determine if the parser should allow defaults when creating the object

ParseHeaders *(bool) = true

Determine if the parser should handle the first line in the delimited stream as a header

RemoveEmptyEntries *(bool) = false

Determine if the parser should remove empty entries from the list before using them

Examples

Basic Usage

This is shorthand to not worry about creating the stream reader.

    public class TestModel
    {
        [CsvProperty("name")]
        public string Name { get; set; }
        [CsvProperty("type")]
        public TestType Type { get; set; }
        [CsvProperty("cost")]
        public int Cost { get; set; }
        [CsvProperty("id")]
        public int Id { get; set; }
    }

    public enum TestType
    {
        Attachment,
        Effect,
        Spell,
        Structure
    }

    ...
    var list = CsvParser.Parse("test.csv", new CsvStreamOptions() { RemoveEmptyEntries = true });
    // List<TestModel>
    //      { Name = "Claws", Type = TestType.Attachment, Cost = 10, Id = 1 }
    //      { Name = "Double Edge Sword", Type = TestType.Attachment, Cost = 10, Id = 2 }
    //      { Name = "Gauntlet", Type = TestType.Attachment, Cost = 10, Id = 3 }
    //      { Name = "Leather Armour", Type = TestType.Attachment, Cost = 15, Id = 4 }
    //      ...
    ...

test.csv

name,type,cost,id,final
Claws,Attachment,10,"1",
Double Edge Sword,Attachment,10,2,
Gauntlet,Attachment,10,3,"Final, Test"
Leather Armour,Attachment,15,4,
Wings,Attachment,15,5,
Control,Effect,10,6,
,,,,
Ensnare,Effect,15,7,
Healing Spring,Effect,15,8,
Katee's Inferno,Effect,20,9,
Tornado,Effect,25,10,
Destroy Attachment,Spell,10,11,
Fireball,Spell,5,12,
,,,,
Heal,Spell,5,13,
Lightning Bolt,Spell,10,14,
Teleport,Spell,10,15,
Armory,Structure,15,16,
Blacksmith,Structure,15,17,
"""Magma"" Fissure",Structure,15,18,
"Medical,Healing Camp",Structure,15,19,
Spire,Structure,5,20,
,,,,
,,,,

Stream Usage

Basic Usage for stream objects

    using (var reader = new CsvStreamReader<TestModel>(stream))
    {
        foreach (var item in reader.AsEnumerable())
        {
            ... Do stuff with item
        }
    }

Large Data Files

Large data files need to be processed differently because some of them will not be able to be held in memory very easily.

    using (var reader = new CsvStreamReader<LargeModel>("large.csv", new CsvStreamOptions() { ParseHeaders = false }))
    {
        reader.ForEach(x => {
            ... Process each in the foreach
        });
    }

License

SimpleCsvParser.Core is licensed under the Microsoft Public License

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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 Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.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.

Version Downloads Last updated
2.0.5 353 12/6/2023
2.0.4 1,280 7/18/2022
2.0.3 460 7/15/2022
2.0.2 451 7/14/2022
2.0.1 541 5/25/2022
2.0.0 455 5/25/2022
1.2.4 6,285 3/30/2020
1.2.3 2,611 8/21/2019
1.2.2 560 8/13/2019
1.2.1 565 8/9/2019
1.2.0 572 8/7/2019
1.1.3 1,339 1/1/2019
1.1.2 665 12/28/2018
1.1.1 698 11/10/2018
1.1.0 889 6/15/2018
1.0.5 926 6/8/2018
1.0.4 910 6/8/2018
1.0.3 939 6/8/2018
1.0.2 918 6/7/2018
1.0.1 951 6/7/2018
1.0.0 836 6/7/2018