Skip to content

Commit

Permalink
Merge pull request #3 from erik1066/develop
Browse files Browse the repository at this point in the history
Renamed to RapidCsv
  • Loading branch information
erik1066 authored Aug 27, 2024
2 parents 0a4080a + d33d66e commit 7be1c74
Show file tree
Hide file tree
Showing 52 changed files with 53 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Benchmarks.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Benchmark Results

Benchmarks are run using BenchmarkDotNet. You can run these benchmarks yourself quite easily; just navigate to `tests/FastCsv.Benchmarks` and run `dotnet -c Release` in a terminal.
Benchmarks are run using BenchmarkDotNet. You can run these benchmarks yourself quite easily; just navigate to `tests/RapidCsv.Benchmarks` and run `dotnet -c Release` in a terminal.

| Method | Mean | Error | StdDev | Median | Min | Max | Gen0 | Gen1 | Gen2 | Allocated |
|------------------------------------ |--------------:|--------------:|--------------:|--------------:|--------------:|--------------:|-----------:|----------:|----------:|-------------:|
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Fast CSV Validator and Transformer

[![NuGet version (RapidCsv)](https://img.shields.io/nuget/v/RapidCsv?style=flat-square)](https://www.nuget.org/packages/RapidCsv/)

A .NET library for fast and efficient validation and transformation of CSV files.

Structural CSV validation rules adhere to [RFC 4180](https://www.rfc-editor.org/rfc/rfc4180).
Expand All @@ -10,17 +12,17 @@ Additional content validation rules can be configured by supplying an *optional*

RFC 4180 validation on a 40 column, 100,000 row CSV file takes 235 ms and allocates a total of 100 MB of memory on an old Intel laptop CPU from the 2010s. See [benchmark results](./Benchmarks.md) for more.

You can run benchmarks using a special benchmarking project by navigating to `tests/FastCsv.Benchmarks` and running `dotnet run -c Release`.
You can run benchmarks using a special benchmarking project by navigating to `tests/RapidCsv.Benchmarks` and running `dotnet run -c Release`.

## Basic Usage - Validate a CSV file against [RFC 4180](https://www.rfc-editor.org/rfc/rfc4180)

1. Add a reference to FastCsv in your `.csproj` file:
1. Add a reference to RapidCsv in your `.csproj` file:

```xml
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\src\FastCsv\FastCsv.csproj" />
<ProjectReference Include="..\..\src\RapidCsv\RapidCsv.csproj" />
</ItemGroup>

<PropertyGroup>
Expand All @@ -33,12 +35,12 @@ You can run benchmarks using a special benchmarking project by navigating to `te
</Project>
```

2. Add a `using FastCsv;` directive at the top of your class file.
2. Add a `using RapidCsv;` directive at the top of your class file.

3. Create a `CsvValidator` object and call its `Validate` method, passing both a stream and a `ValidationOptions` object into that method.

```cs
using FastCsv;
using RapidCsv;

string csvContent = @"NAME,AGE,DOB
John,23,1/1/2012
Expand Down Expand Up @@ -71,11 +73,11 @@ static Stream GenerateStreamFromString(string s)

## Examples

The [examples](/examples/) folder contains example code that demonstrates how to use FastCsv.
The [examples](/examples/) folder contains example code that demonstrates how to use RapidCsv.

### Simplest Example: .NET Console App

Let's look at the `FastCsv.ConsoleDemo` project.
Let's look at the `RapidCsv.ConsoleDemo` project.

1. Navigate to [examples/demo-console/](examples/demo-console/) in a terminal of your choice.
1. Enter the following into the terminal:
Expand Down Expand Up @@ -105,7 +107,7 @@ That's all there is to it.
## Architecture and Design Decisions

FastCsv is meant to be used in situations where one needs speed and memory efficiency _at scale_. For instance, if you're required to process CSV files in near real-time at high volume, where validation results are viewable by clients almost instantly after file submission, then this is a library worth considering.
RapidCsv is meant to be used in situations where one needs speed and memory efficiency _at scale_. For instance, if you're required to process CSV files in near real-time at high volume, where validation results are viewable by clients almost instantly after file submission, then this is a library worth considering.

This is also why the library was built and shapes the design decisions around why the code is written the way it is.

Expand All @@ -119,7 +121,7 @@ A state machine-like algorithm is needed to parse each line in a CSV file. The a

### No limits on file size

FastCsv operates on streams. The whole CSV file does not need to be read at once, unlike some other competing libraries, and the fast performance means even larger files (e.g. 100k rows) can be validated in under 1 second.
RapidCsv operates on streams. The whole CSV file does not need to be read at once, unlike some other competing libraries, and the fast performance means even larger files (e.g. 100k rows) can be validated in under 1 second.

### Human-readable error messages

Expand Down Expand Up @@ -149,7 +151,7 @@ There are more advanced things you can do with the `Validate` method such as spe

### Few to no dependencies

The software supply chain is hard to secure today. FastCsv currently uses no dependencies.
The software supply chain is hard to secure today. RapidCsv currently uses no dependencies.

### Configurable content validation rules

Expand Down
2 changes: 1 addition & 1 deletion examples/demo-console/FastCsv.ConsoleDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\src\FastCsv\FastCsv.csproj" />
<ProjectReference Include="..\..\src\RapidCsv\RapidCsv.csproj" />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using FastCsv;
using RapidCsv;

string csvContent = @"NAME,AGE,DOB
John,23,1/1/2012
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-console/demo-console.generated.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastCsv.ConsoleDemo", "FastCsv.ConsoleDemo.csproj", "{05815FA9-F697-46B4-849C-19F9B324B3CE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RapidCsv.ConsoleDemo", "RapidCsv.ConsoleDemo.csproj", "{05815FA9-F697-46B4-849C-19F9B324B3CE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
6 changes: 3 additions & 3 deletions fast-csv.sln → rapid-csv.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{586D083E-4309-4C41-91E7-D37F5277AA2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastCsv", "src\FastCsv\FastCsv.csproj", "{F9ADE669-75BA-4853-A763-3B241241DC21}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RapidCsv", "src\RapidCsv\RapidCsv.csproj", "{F9ADE669-75BA-4853-A763-3B241241DC21}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{07E5EE3A-1CCA-44B9-B287-4E869481937C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastCsv.Tests", "tests\FastCsv.Tests\FastCsv.Tests.csproj", "{93969D81-3765-4A43-9507-6121F010BFEA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RapidCsv.Tests", "tests\RapidCsv.Tests\RapidCsv.Tests.csproj", "{93969D81-3765-4A43-9507-6121F010BFEA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastCsv.Benchmarks", "tests\FastCsv.Benchmarks\FastCsv.Benchmarks.csproj", "{CBDE39E4-9A32-4850-AED9-014CB6759287}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RapidCsv.Benchmarks", "tests\RapidCsv.Benchmarks\RapidCsv.Benchmarks.csproj", "{CBDE39E4-9A32-4850-AED9-014CB6759287}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Text.Json;
using System.Xml;

namespace FastCsv;
namespace RapidCsv;

public class CsvFieldValidator : IFieldValidator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace FastCsv;
namespace RapidCsv;

public class CsvValidator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FastCsv;
namespace RapidCsv;

public interface IFieldValidator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.ObjectModel;

namespace FastCsv;
namespace RapidCsv;

public class ProcessRowOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.ObjectModel;

namespace FastCsv;
namespace RapidCsv;

public class ProcessRowResult
{
Expand Down
5 changes: 5 additions & 0 deletions src/FastCsv/FastCsv.csproj → src/RapidCsv/RapidCsv.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Owners>eknudsen</Owners>
<NeutralLanguage>en-US</NeutralLanguage>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -21,4 +22,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/FastCsv/Severity.cs → src/RapidCsv/Severity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FastCsv;
namespace RapidCsv;

public enum Severity
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;

namespace FastCsv;
namespace RapidCsv;

public class ValidationColumnProfile
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;

namespace FastCsv;
namespace RapidCsv;

[DebuggerDisplay("{Severity} : {Content}")]
public sealed class ValidationMessage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FastCsv;
namespace RapidCsv;

public enum ValidationMessageType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FastCsv;
namespace RapidCsv;

public class ValidationOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json.Serialization;

namespace FastCsv;
namespace RapidCsv;

public class ValidationProfile
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.ObjectModel;

namespace FastCsv;
namespace RapidCsv;

public class ValidationResult
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using BenchmarkDotNet.Running;

namespace FastCsv.Benchmarks;
namespace RapidCsv.Benchmarks;

public static class Program
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\src\FastCsv\FastCsv.csproj" />
<ProjectReference Include="..\..\src\RapidCsv\RapidCsv.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Reflection;
using BenchmarkDotNet.Attributes;

namespace FastCsv.Benchmarks;
namespace RapidCsv.Benchmarks;

[MemoryDiagnoser]
[MinColumn, MaxColumn]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public sealed class CsvContentValidation_Enum_Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public sealed class CsvContentValidation_String_Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public class CsvFieldValidator_Boolean_Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Globalization;
using System.Text.Json;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public class CsvFieldValidator_Decimal_Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public class CsvFieldValidator_Integer_Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public class CsvFieldValidator_String_Format_Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public class CsvFieldValidator_String_Length_Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public class CsvFieldValidator_String_Regex_Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public class CsvFieldValidator_String_Required_Tests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Diagnostics;
using FastCsv;
using RapidCsv;
using Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.ObjectModel;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public class CsvStructuralValidatorTests
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\FastCsv\FastCsv.csproj" />
<ItemGroup>
<ProjectReference Include="..\..\src\RapidCsv\RapidCsv.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Text.Json;

namespace FastCsv.Tests;
namespace RapidCsv.Tests;

public sealed class ValidationProfileTests
{
Expand Down

0 comments on commit 7be1c74

Please sign in to comment.