CsvReaderAdvanced 1.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package CsvReaderAdvanced --version 1.0.4
                    
NuGet\Install-Package CsvReaderAdvanced -Version 1.0.4
                    
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="CsvReaderAdvanced" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CsvReaderAdvanced" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="CsvReaderAdvanced" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CsvReaderAdvanced --version 1.0.4
                    
#r "nuget: CsvReaderAdvanced, 1.0.4"
                    
#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.
#:package CsvReaderAdvanced@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CsvReaderAdvanced&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=CsvReaderAdvanced&version=1.0.4
                    
Install as a Cake Tool

CsvReaderAdvanced

The faster and most modern CSV reader adapted to DI principles.

How to use

First add the service to the ServiceCollection.

 builder.ConfigureServices((context, services) =>
        {
            services.AddCsvReader(context.Configuration);
        ...

To understand exactly what the method does, it assumes that the current configuration file contains a csvSchemas section, typically in the appsettings.json file:

public static IServiceCollection AddCsvReader(this IServiceCollection services, IConfiguration configuration)
{
    services.AddSingleton<ICsvReader,CsvReader>();
    services.AddTransient<ICsvFile,CsvFile>();

    //Microsoft.Extensions.Hosting must be referenced
    services.Configure<CsvSchemaOptions>(configuration.GetSection(CsvSchemaOptions.CsvSchemasSection));
    return services;
}

The schema in the appsettings.json file typically contains a property named csvSchemas:

"csvSchemas": {
    "schemas": [
      {
        "name": "shipments",
        "fields": [
          {
            "name": "ClientShipmentID",
            "alternatives": [ "Client Shipment ID", "Client shipmentid" ],
            "required": true
          },
          {
            "name": "Weight",
            "unit": "t",
            "alternativeFields": [ "Volume", "TEU" ],
            "required": true
          },
          {
            "name": "Volume",
            "unit": "m^3",
            "alternativeUnits": [ "m3", "m^3", "m�" ]
...

We assume that we get the options via DI like the following example:

public Importer(
    IUnitOfWork context,
    IMapper mapper,
    IServiceProvider provider,
    ILogger logger,
    IOptions<CsvSchemaOptions> options)
{
    _context = context;
    _mapper = mapper;
    _provider = provider;
    _logger = logger;
    _options = options.Value;
}

protected readonly IUnitOfWork _context;
protected readonly IMapper _mapper;
protected readonly IServiceProvider _provider;
protected readonly ILogger _logger;
protected readonly CsvSchemaOptions _options;

public CsvSchema? GetSchema(string name) =>
    _options?.Schemas?.FirstOrDefault(s => s.Name == name);

public ValidationResult CheckForSchema(string name)
{
    if (_options?.Schemas is null || !_options.Schemas.Any())
    {
        _logger.LogError("Could not retrieve csv schemas from settings");
        return new ValidationResult(
            new ValidationFailure[] { new ValidationFailure("CsvSchemas", "Cannot retrieve csv schemas from settings") });
    }

    var schema = GetSchema(name);

    if (schema is null)
    {
        _logger.LogError("Could not retrieve '{schemaName}' schema from settings",name);
        return new ValidationResult(
            new ValidationFailure[] { new ValidationFailure("clientSites", $"Cannot retrieve '{name}' schema from settings") });
    }
    return new ValidationResult();

}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on CsvReaderAdvanced:

Package Downloads
SqlServerExplorerLib

The easiest way to perform SQL Server operations, such as viewing table fields, copying table data to a file, or transferring table data between databases. See the README for more information.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.7.1 101 7/15/2026
2.6.0 493 2/23/2025
2.5.0 250 1/17/2025
2.4.1 227 12/27/2024
2.4.0 446 11/15/2024
2.3.8 429 10/16/2024
2.3.7 313 7/27/2024
2.3.6 254 7/27/2024
2.3.5 222 7/26/2024
2.3.4 256 7/12/2024
2.3.3 267 6/22/2024
2.3.2 298 6/22/2024
2.3.1 925 3/1/2024
2.3.0 404 12/13/2023
2.2.1 265 11/28/2023
2.2.0 327 10/17/2023
2.1.1 272 10/15/2023
2.1.0 244 10/15/2023
1.3.3 252 10/14/2023
1.0.4 334 6/16/2023 1.0.4 is deprecated because it is no longer maintained.
Loading failed