Installation

Install the package via pip or from source code using Git.

pip install data-utils-py

Or install from source:

git clone https://github.com/yourusername/data-utils
cd data-utils
python setup.py install
Overview

The data_utils package provides helper functions for various utility tasks in data processing.

  • String manipulation
  • Numerical calculations
  • List processing
  • File handling
  • Date & time conversion
  • Data validation
Getting Started

This example shows how to import the library and use a simple function.

from data_utils import strings, numbers, lists, dates

# Capitalize every word in a sentence
result = strings.title_case("hello world")
print(result)  # Output: Hello World
String Utilities

Use these functions to modify and clean up string data easily.

Functions:

  • title_case(text: str) -> str
  • remove_special_characters(text: str) -> str
  • reverse_string(text: str) -> str

Example

print(strings.remove_special_characters("Hello@#%$ World!!"))
# Output: Hello World
print(strings.reverse_string("python"))
# Output: nohtyp
Number Utilities

Basic mathematical operations and number handling made simple.

Functions:

  • is_prime(n: int) -> bool
  • factorial(n: int) -> int
  • average(numbers: List[float]) -> float

Example

print(numbers.is_prime(13))  # Output: True
print(numbers.factorial(5)) # Output: 120
print(numbers.average([10, 20, 30])) # Output: 20.0
List Utilities

Tools for working with lists, like flattening and chunking.

Functions:

  • flatten(nested_list: List) -> List
  • unique(items: List) -> List
  • chunks(lst: List, n: int) -> Generator[List, None, None]

Example

print(lists.flatten([[1, 2], [3, 4]]))
# Output: [1, 2, 3, 4]

print(lists.unique([1, 1, 2, 3]))
# Output: [1, 2, 3]
Date and Time Utilities

These functions help with formatting, parsing, and computing dates and times.

Functions:

  • parse_date(date_str: str, fmt: str) -> datetime
  • format_date(date_obj: datetime, fmt: str) -> str
  • time_diff(start: datetime, end: datetime) -> timedelta

Example

dt = dates.parse_date("2025-07-06", "%Y-%m-%d")
print(dates.format_date(dt, "%d %b %Y"))
# Output: 06 Jul 2025
Validation Functions

Functions to validate common inputs like email, phone, and passwords.

Functions:

  • is_valid_email(email: str) -> bool
  • is_valid_phone(number: str) -> bool
  • is_strong_password(password: str) -> bool

Example

print(validation.is_valid_email("user@example.com"))
# Output: True

print(validation.is_strong_password("abc123"))
# Output: False
File Utilities

Read and write files and JSON with these easy-to-use utilities.

Functions:

  • read_file(path: str) -> str
  • write_file(path: str, data: str) -> None
  • read_json(path: str) -> dict

Example

file_utils.write_file("sample.txt", "Hello World")
print(file_utils.read_file("sample.txt"))
# Output: Hello World
Logging and Debugging

Log important messages or errors while developing your application.

Functions:

  • log_info(msg: str)
  • log_error(msg: str)

Example

logger.log_info("Script started")
logger.log_error("Something went wrong")
Advanced Usage

Combine utilities to perform powerful data operations with minimal code.

text = "hello@python!"
clean = strings.remove_special_characters(text)
reverse = strings.reverse_string(clean)
print(reverse)
# Output: nohtypolleH
Reference

All the documentation in this page is taken from Python Docs