TxtCsvHelper 1.2.8
See the version list below for details.
dotnet add package TxtCsvHelper --version 1.2.8
NuGet\Install-Package TxtCsvHelper -Version 1.2.8
<PackageReference Include="TxtCsvHelper" Version="1.2.8" />
paket add TxtCsvHelper --version 1.2.8
#r "nuget: TxtCsvHelper, 1.2.8"
// Install TxtCsvHelper as a Cake Addin #addin nuget:?package=TxtCsvHelper&version=1.2.8 // Install TxtCsvHelper as a Cake Tool #tool nuget:?package=TxtCsvHelper&version=1.2.8
TxtCsvHelper
TxtCsvHelper is a library to assist in parsing CSV, or any other form of delimited files. You can fill models, fill dynamics, or simply get a list of fields by line.
Installation
Use the package manager console to install TxtCsvHelper.
Install-Package TxtCsvHelper -Version 1.2.8
Usage
using TxtCsvHelper;
To return an IEnumerable<T>. Dynamic types must be IEnumerable<dynamic> Parser can take a Stream, StreamReader, ReadStream, FileStream, MemoryStream or a string followed by 3 optional parameters: the delimiter character (will default to a comma). A bool if there is a header line (will default to true). A bool if there are spaces between delimiters and fields (will default to false). Deserialize takes a type.
using(Parser pars = new Parser(streamvar, delimiter: ',', hasHeader: true, hasSpaces: false))
{
var models = pars.Deserialize<Person>();
}
To return an IEnumerable<string> for each line, call using StreamReader. If fields may have a line break use ReadStream instead of StreamReader. ReadStream is called with the exact syntax as StreamReader. Parser in this case takes 3 optional parameters: the delimiter character (will default to a comma). A bool if there is a header line (will default to true). A bool if there are spaces between delimiters and fields (will default to false). SplitLine takes a Line of delimited fields. Followed by 2 optional parameters: the delimiter character (will default to a comma). A bool if there are spaces between delimiters and fields (will default to false)
using (StreamReader sr = new StreamReader(postedFile.OpenReadStream()))
using(Parser pars = new Parser())
{
while(sr.Peek() >= 0)
var substrings = pars.SplitLine(sr.ReadLine());
//do something with the strings
}
To return an IEnumerable<string> for each line, call using StreamReader. If fields may have a line break use ReadStream instead of StreamReader. ReadStream is called with the exact syntax as StreamReader. Only use this if fields may or may not be quoted (and contain a delimiter), otherwise use .SplitLine(). Parser in this case takes 3 optional parameters: the delimiter character (will default to a comma). A bool if there is a header line (will default to true). A bool if there are spaces between delimiters and fields (will default to false). SplitLine takes a Line of delimited fields. Followed by 2 optional parameters: the delimiter character (will default to a comma). A bool if there are spaces between delimiters and fields (will default to false)
using (StreamReader sr = new StreamReader(postedFile.OpenReadStream()))
using(Parser pars = new Parser())
{
while(sr.Peek() >= 0)
var substrings = pars.SplitLine(sr.ReadLine());
//do something with the strings
}
If no header exists, you may declare the index of the field in the model with [SetIndex()] simply put the index starting with 0 inside the parentheses If a header exists but the names do not match your model, you may declare the header name with [HeaderName()] simply put the column name in the parentheses
public class Person
{
[SetIndex(1)]
[HeaderName(Last)]
public string LastName { get; set; }
[SetIndex(0)]
public string FirstName { get; set; }
[SetIndex(2)]
public string MiddleName { get; set; }
[SetIndex(3)]
public int Age { get; set; }
}
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
- Microsoft.CSharp (>= 4.7.0)
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.3.3 | 3,975 | 6/24/2022 |
1.3.2 | 457 | 6/20/2022 |
1.3.1 | 686 | 8/2/2021 |
1.3.0 | 397 | 8/1/2021 |
1.2.9 | 390 | 7/12/2021 |
1.2.8 | 408 | 7/1/2021 |
1.2.7 | 393 | 6/21/2021 |
1.2.6 | 341 | 6/21/2021 |
1.2.5 | 372 | 5/17/2021 |
1.2.4 | 373 | 5/15/2021 |
1.2.3 | 368 | 5/11/2021 |
1.2.2 | 342 | 5/10/2021 |
1.2.1 | 331 | 5/9/2021 |
1.2.0 | 350 | 5/9/2021 |
1.1.9 | 357 | 5/9/2021 |
1.1.8 | 420 | 5/8/2021 |
1.1.7 | 356 | 5/8/2021 |
1.1.6 | 348 | 5/8/2021 |
1.1.5 | 410 | 5/7/2021 |
1.1.4 | 410 | 5/7/2021 |
1.1.3 | 429 | 5/7/2021 |
1.1.2 | 401 | 5/6/2021 |
1.1.1 | 361 | 5/6/2021 |
1.1.0 | 377 | 5/6/2021 |
1.0.1 | 373 | 5/6/2021 |
1.0.0 | 366 | 5/6/2021 |