SimpleCsvParser.Core
1.1.0
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
<PackageReference Include="SimpleCsvParser.Core" Version="1.1.0" />
paket add SimpleCsvParser.Core --version 1.1.0
#r "nuget: SimpleCsvParser.Core, 1.1.0"
// 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 | Versions 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. |
-
.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 | 785 | 12/6/2023 |
2.0.4 | 1,320 | 7/18/2022 |
2.0.3 | 493 | 7/15/2022 |
2.0.2 | 478 | 7/14/2022 |
2.0.1 | 568 | 5/25/2022 |
2.0.0 | 482 | 5/25/2022 |
1.2.4 | 6,312 | 3/30/2020 |
1.2.3 | 3,046 | 8/21/2019 |
1.2.2 | 586 | 8/13/2019 |
1.2.1 | 586 | 8/9/2019 |
1.2.0 | 597 | 8/7/2019 |
1.1.3 | 1,613 | 1/1/2019 |
1.1.2 | 695 | 12/28/2018 |
1.1.1 | 726 | 11/10/2018 |
1.1.0 | 918 | 6/15/2018 |
1.0.5 | 953 | 6/8/2018 |
1.0.4 | 938 | 6/8/2018 |
1.0.3 | 967 | 6/8/2018 |
1.0.2 | 949 | 6/7/2018 |
1.0.1 | 980 | 6/7/2018 |
1.0.0 | 864 | 6/7/2018 |