DelimitedParser 1.0.0
dotnet add package DelimitedParser --version 1.0.0
NuGet\Install-Package DelimitedParser -Version 1.0.0
<PackageReference Include="DelimitedParser" Version="1.0.0" />
paket add DelimitedParser --version 1.0.0
#r "nuget: DelimitedParser, 1.0.0"
// Install DelimitedParser as a Cake Addin
#addin nuget:?package=DelimitedParser&version=1.0.0
// Install DelimitedParser as a Cake Tool
#tool nuget:?package=DelimitedParser&version=1.0.0
Delimited Parser
DelimitedParser convert your delimited file text into a model class. Is a simple way to parse files with delimited format.
Getting Starter
Let's suppose that you have the following file delimited below:
TESTING_01;TESTING_02;TESTING_03
testing1;10;true
testing2;20;false
testing3;30;true
testing4;40;false
testing5;50;true
And you need to convert this format into a model class. With this library you can to do that easily. The first step is create a model with a custom attribute called "DelimitedHeader", the custom attribute "DelimitedHeader" is the header name into a delimited file, the code below explain how to create this model.
using GenericParser.Attribute;
namespace GenericParser.Emulator
{
public class TestingModel
{
[DelimitedHeader("TESTING_01")]
public string TestingPropString { get; set; }
[DelimitedHeader("TESTING_02", DefaultValue = 0)]
public int TestingPropInt { get; set; }
[DelimitedHeader("TESTING_03")]
public bool TestingPropBool { get; set; }
}
}
After you created a custom model, the only step after is create an instance of the class, passing you model type and informing you type of delimiter char
using GenericParser.DelimitedParser.Parser;
namespace GenericParser.Emulator
{
class Program
{
static void Main(string[] args)
{
var filePath = @"C:\FileWithHeaderTesting.csv";
var delimitedParser = new DelimitedParser<TestingModel>(filePath)
{
Delimitator = ';'
};
var model = delimitedParser.Parse();
}
}
}
If your delimited file there's no line "Header", not problem! It's also possible to use this library, instead of use the class "DelimitedParser", use the class "DelimitedWithoutHeaderParser", and than informing a string supposing a header into a delimited file:
using GenericParser.DelimitedParser.Parser;
namespace GenericParser.Emulator
{
class Program
{
static void Main(string[] args)
{
var filePath = @"C:\FileWithoutHeaderTesting.csv";
var delimitedParser = new DelimitedWithoutHeaderParser<TestingModel>(filePath)
{
Delimitator = ';',
HeaderFile = "TESTING_01;TESTING_02;TESTING_03"
};
var model = delimitedParser.Parse();
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
This package has 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 |
---|---|---|
1.0.0 | 868 | 8/6/2018 |