TheDataCity.Utilities 1.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package TheDataCity.Utilities --version 1.2.1
                    
NuGet\Install-Package TheDataCity.Utilities -Version 1.2.1
                    
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="TheDataCity.Utilities" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TheDataCity.Utilities" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="TheDataCity.Utilities" />
                    
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 TheDataCity.Utilities --version 1.2.1
                    
#r "nuget: TheDataCity.Utilities, 1.2.1"
                    
#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 TheDataCity.Utilities@1.2.1
                    
#: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=TheDataCity.Utilities&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=TheDataCity.Utilities&version=1.2.1
                    
Install as a Cake Tool

TheDataCity.Utilities

A .NET utilities library providing structured logging, timing helpers, string utilities, company web-text cleaning, and DuckDB table definition generation.

Installation

dotnet add package TheDataCity.Utilities

Or via Package Manager Console:

Install-Package TheDataCity.Utilities

Quick Start

Logging

using TheDataCity.Utilities;

// Initialize logger once at startup
Log.InitialiseWithConsole("MyApp");

// Use Log
Log.Info("Processing started");
Log.Info("Processed {Count} items", itemCount);
Log.Error("Something went wrong");
Log.Warning("This is a warning");
Log.Debug("Debug information");

Timing Operations

using TheDataCity.Utilities;

// Automatic timing with using statement
using (new TimingHelper("Processing data"))
{
    // Your code here
    // Automatically logs completion time when disposed
}

// Or use the static Timing class
var (result, elapsed) = Timing.TimeOperation("Calculate result", () => {
    return PerformCalculation();
});

String Utilities

using TheDataCity.Utilities;

// Get first word from a string
string firstWord = StringUtilities.GetFirstWord("Hello World"); // "Hello"

// Normalise website URLs
string normalised = StringUtilities.NormaliseWebsite("https://www.example.com/"); // "example.com"

// Normalise company names (period / ampersand spacing)
string normalised = StringUtilities.NormaliseCompanyName("A.B.C. & Co."); // "ABC & Co"

// SearchName / name-filter needle (drop punctuation except &, collapse spaces)
string searchName = StringUtilities.NormaliseSearchName("Reno's of Wise, LLC").ToUpperInvariant(); // "RENOS OF WISE LLC"

Company web-text cleaning

using TheDataCity.Utilities;

(string? cleaned, CleaningStats stats) = CompanyTextCleaner.CleanText(rawWebText);
string status = CompanyTextCleaner.QualityStatusName(stats.QualityStatus);

// Only the foreign-char step (non-Latin scripts and emoji); line breaks are kept
string latinOnly = CompanyTextCleaner.StripForeignChars(line).Text;

CompanyTextCleaner is the canonical C# cleaner for company website text (boilerplate strip, foreign-char strip, paragraph/sentence dedup, n-gram phrase dedup, quality classification). Prefer this package over local copies.

DuckDB Table Generation

using TheDataCity.Utilities.Attributes.DuckDB;
using TheDataCity.Utilities.DuckDB;

[TableName("custom_table_name")]
public class MyModel
{
    [ColumnName("id")]
    [NotNull]
    public int Id { get; set; }

    [DuckDBType("VARCHAR")]
    public string Name { get; set; }

    [ExcludeFromTable]
    public string IgnoredProperty { get; set; }
}

// Generate CREATE TABLE statement
string createTableSql = TableDefinitionGenerator.GenerateCreateTable<MyModel>();

Writing objects to parquet

ParquetObjectWriter<T> writes objects through ParquetSharp, with one column per public property, mapped by the same rules as Parquet.Net's ParquetSerializer (retired on 10 November 2026). Nested classes and lists become structs and lists, and [ParquetIgnore] and [JsonIgnore] properties are skipped. Each call maps its objects to Arrow in parallel slices, and DuckDB reads the file just as it read Parquet.Net's.

using TheDataCity.Utilities.Parquet;

using ParquetObjectWriter<Company> writer = new("Companies.parquet", rowsPerRowGroup: 250_000);
writer.Write(companies);       // as many calls as needed; row groups fill to size across calls
writer.Close();                // without this, disposing the writer deletes the file

Supported property types: string, int, long, double, float, bool, DateOnly, DateTime, enums, their nullable forms, arrays, List<T> and classes. Any other type throws NotSupportedException when the writer is created.

Required input checks

Mark each input path a pipeline needs with [RequiredAtStartup], then check them all at startup. If any are missing, the run stops with one error listing every missing file, instead of a data loader failing partway through.

using TheDataCity.Utilities;
using TheDataCity.Utilities.Attributes;
using TheDataCity.Utilities.Enums;

public static class RequiredAssetPaths
{
    // Use properties (=>) so paths are built after configuration is loaded.
    [RequiredAtStartup("Companies parquet")]
    public static string Companies => ApplicationConfiguration.GetAssetsPathWithVersion("Companies", FileType.Parquet);

    [RequiredAtStartup("Third-party data folder", isDirectory: true)]
    public static string ThirdPartyData => ApplicationConfiguration.GetAssetsPath("ThirdPartyData");
}

// Throws InvalidOperationException listing every missing asset
RequiredAssetValidator.EnsureExists(typeof(RequiredAssetPaths));

// Or inspect without throwing
IReadOnlyList<RequiredAsset> missing = RequiredAssetValidator.FindMissing(typeof(RequiredAssetPaths));

The attribute works on static string fields and properties, public or private. Pass several types to check them together.

Features

  • Structured Logging - Source-generated logging using .NET ILogger with automatic timestamp formatting
  • Timing Helpers - Automatic timing and logging of code blocks with intelligent operation name transformation
  • String Utilities - String manipulation and normalisation methods for common use cases
  • Company Web-Text Cleaning - Shared CompanyTextCleaner for pipeline web-text cleaning
  • DuckDB Integration - Generate DuckDB table definitions from C# models with customisable attributes
  • Parquet Writing - Write objects to parquet through ParquetSharp, with the columns Parquet.Net wrote
  • Required Input Checks - Fail fast at startup when any [RequiredAtStartup] input file or folder is missing

Requirements

  • .NET 10.0 or later

License

MIT License

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 is compatible.  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

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.2.2 13 12/2/2026
1.2.1 22 12/2/2026
1.2.0 25 12/2/2026
1.1.1 2,005 11/12/2026
1.1.0 115 11/12/2026
1.0.34 4,238 9/30/2026
1.0.33 632 9/28/2026
1.0.32 137 9/28/2026
1.0.31 1,728 8/3/2026
1.0.30 525 7/31/2026
1.0.29 305 7/29/2026
1.0.28 349 7/29/2026
1.0.27 304 7/24/2026
1.0.26 4,313 3/23/2026
1.0.25 1,009 3/2/2026
1.0.24 685 2/23/2026
1.0.23 990 1/29/2026
1.0.22 495 1/28/2026
1.0.21 286 1/22/2026
1.0.20 151 1/22/2026
Loading failed