Skip to main content

A utility library for data cleaning and parsing.

Project description

smith-utils

PyPI version Python versions Status License Tests Documentation Status

Smith Utils is a central hub for data cleaning and parsing scripts. This package consolidates distributed utility functions to improve code reuse and maintenance efficiency across all yeiichi projects.

Key Features

📅 Datetime Utilities (smith_utils.datetime)

Robust date parsing and formatting.

  • ensure_date: Flexible conversion of strings, datetime.date objects, or None (returns today) into a date object.
  • parse_strict_date: Strict parsing for YYYYMMDD or YYYY-MM-DD formats, rejecting ambiguous inputs.
  • format_ordinal: Converts integers to ordinal strings (e.g., 1"1st", 22"22nd").

🔢 Numeric Refinement (smith_utils.numeric)

Clean and parse messy numeric data.

  • parse_numeric_value: Handles custom separators, decimals, and negative formats like (1,234.56).
  • parse_currency_value: Alias for numeric parsing, specifically for currency strings.

📝 Text Normalization & Metrics (smith_utils.text)

Standardize text and compare string similarity.

  • normalize_text: Unicode NFKC normalization, case folding, and whitespace handling.
  • StringDistance: Implementation of Damerau-Levenshtein and Jaro-Winkler algorithms for fuzzy matching.
  • make_unicode_char_name_records: Extract Unicode codepoint/name metadata from text.

Installation

Install via pip:

pip install smith-utils

Quick Start

from smith_utils import ensure_date, parse_numeric_value, normalize_text
from smith_utils import make_unicode_char_name_records

# Datetime
date = ensure_date("20231225") # datetime.date(2023, 12, 25)

# Numeric
value = parse_numeric_value("(1,250.50)") # -1250.5

# Text
clean_text = normalize_text("  Smith  Utils  ") # "smith utils"

# Unicode metadata
records = make_unicode_char_name_records("Aあ")
# [UnicodeCharNameRecord(index=0, codepoint='U+0041', ...), ...]

Directory Structure

  • src/smith_utils/: Main package source.
  • legacy/: Legacy scripts and templates (not included in distribution).
  • tests/: Comprehensive test suite.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smith_utils-0.2.1.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smith_utils-0.2.1-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file smith_utils-0.2.1.tar.gz.

File metadata

  • Download URL: smith_utils-0.2.1.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for smith_utils-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2fbd47ed529250b796891b81b5dff22fcfaa8e7279a26d9e01227e4373fc511c
MD5 efe1aa1e8aaaa2ed09c94c268fb400c9
BLAKE2b-256 4fc0326f58d04f78d6e6cfd13e5340984ddeba0e56bbf70c51fe4b05fa00322c

See more details on using hashes here.

File details

Details for the file smith_utils-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: smith_utils-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for smith_utils-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 932098795231ab088c535f3bb18700cf2e3ab565fbf829d52dd35281943d63f2
MD5 f0c1b890acdf6797bce77f4c3dc999e0
BLAKE2b-256 2b41f49cdfee05e0092fc729def35c8f1b59589c22dc0d644ebc5c19a4910cdb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page