splurge-typer


Namesplurge-typer JSON
Version 2025.0.1 PyPI version JSON
download
home_pageNone
SummaryType Inference and Conversion Library for Python
upload_time2025-09-04 21:18:01
maintainerJim Schilling
docs_urlNone
authorJim Schilling
requires_python>=3.10
licenseNone
keywords type-inference data-conversion python typing data-processing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # splurge-typer

**Type Inference and Conversion Library for Python**

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

splurge-typer is a comprehensive Python library for inferring data types from string values and converting between different data representations. It can analyze individual string values or entire collections to determine the most appropriate Python data type.

## Features

- **Single Value Inference**: Automatically detect the data type of individual string values
- **Collection Analysis**: Analyze sequences of values to determine dominant types
- **Type Conversion**: Convert strings to their inferred Python types
- **Comprehensive Type Support**: Handles integers, floats, booleans, dates, times, datetimes, and more
- **Performance Optimized**: Includes incremental processing for large datasets
- **Flexible Parsing**: Supports multiple date/time formats and handles edge cases

## Installation

```bash
# Clone the repository
git clone https://github.com/jim-schilling/splurge-typer.git
cd splurge-typer

# Install in development mode
pip install -e .
```

## Quick Start

### Basic Usage

```python
from splurge_typer import TypeInference, DataType

# Create a type inference instance
ti = TypeInference()

# Single value inference
print(ti.infer_type('123'))        # DataType.INTEGER
print(ti.infer_type('1.23'))       # DataType.FLOAT
print(ti.infer_type('true'))       # DataType.BOOLEAN
print(ti.infer_type('2023-01-01')) # DataType.DATE

# Type conversion
print(ti.convert_value('123'))        # 123 (int)
print(ti.convert_value('1.23'))       # 1.23 (float)
print(ti.convert_value('true'))       # True (bool)
```

### Collection Analysis

```python
# Analyze collections of values
values1 = ['1', '2', '3']
print(ti.profile_values(values1))  # DataType.INTEGER

values2 = ['1.1', '2.2', '3.3']
print(ti.profile_values(values2))  # DataType.FLOAT

values3 = ['1', '2.2', 'hello']
print(ti.profile_values(values3))  # DataType.MIXED
```

## Supported Data Types

The library can infer the following data types:

- `INTEGER`: Whole numbers (`'123'`, `'-456'`, `'00123'`)
- `FLOAT`: Decimal numbers (`'1.23'`, `'-4.56'`, `'1.0'`)
- `BOOLEAN`: True/false values (`'true'`, `'false'`, `'True'`, `'False'`)
- `DATE`: Date values in various formats (`'2023-01-01'`, `'01/01/2023'`, `'20230101'`)
- `TIME`: Time values (`'14:30:00'`, `'2:30 PM'`, `'143000'`)
- `DATETIME`: Combined date and time (`'2023-01-01T12:00:00'`, `'2023-01-01 12:00:00'`)
- `STRING`: Text data that doesn't match other patterns
- `EMPTY`: Empty strings or whitespace-only strings
- `NONE`: Null values (`'none'`, `'null'`, `None`)
- `MIXED`: Collections containing multiple data types

## Advanced Usage

### Handling Edge Cases

```python
# Leading zeros are handled correctly
print(ti.infer_type('00123'))  # DataType.INTEGER

# Invalid dates fall back to string
print(ti.infer_type('2023-13-01'))  # May be interpreted as date in some formats

# Mixed collections
mixed_values = ['123', 'abc', '2023-01-01']
print(ti.profile_values(mixed_values))  # DataType.MIXED
```

### Performance Considerations

For large datasets (>10,000 items), the library automatically enables incremental type checking for better performance:

```python
large_dataset = [str(i) for i in range(50000)]
result = ti.profile_values(large_dataset)  # Uses optimized incremental processing
```

## API Reference

### TypeInference Class

#### Methods

- `infer_type(value: str) -> DataType`: Infer type of a single value
- `convert_value(value: Any) -> Any`: Convert value to its inferred type
- `profile_values(values: Iterable[Any]) -> DataType`: Analyze a collection of values

### String Class

Low-level string processing utilities:

- `is_int_like()`, `is_float_like()`, `is_bool_like()`, etc.
- `to_int()`, `to_float()`, `to_bool()`, etc.
- `infer_type()` - direct type inference

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Author

Jim Schilling (c) 2025

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "splurge-typer",
    "maintainer": "Jim Schilling",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "type-inference, data-conversion, python, typing, data-processing",
    "author": "Jim Schilling",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/ef/b1/0915f6a3bf26f32f11da2e0fb9473cd3c6ab26b4c96e9a8b48adc404824a/splurge_typer-2025.0.1.tar.gz",
    "platform": null,
    "description": "# splurge-typer\r\n\r\n**Type Inference and Conversion Library for Python**\r\n\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n\r\nsplurge-typer is a comprehensive Python library for inferring data types from string values and converting between different data representations. It can analyze individual string values or entire collections to determine the most appropriate Python data type.\r\n\r\n## Features\r\n\r\n- **Single Value Inference**: Automatically detect the data type of individual string values\r\n- **Collection Analysis**: Analyze sequences of values to determine dominant types\r\n- **Type Conversion**: Convert strings to their inferred Python types\r\n- **Comprehensive Type Support**: Handles integers, floats, booleans, dates, times, datetimes, and more\r\n- **Performance Optimized**: Includes incremental processing for large datasets\r\n- **Flexible Parsing**: Supports multiple date/time formats and handles edge cases\r\n\r\n## Installation\r\n\r\n```bash\r\n# Clone the repository\r\ngit clone https://github.com/jim-schilling/splurge-typer.git\r\ncd splurge-typer\r\n\r\n# Install in development mode\r\npip install -e .\r\n```\r\n\r\n## Quick Start\r\n\r\n### Basic Usage\r\n\r\n```python\r\nfrom splurge_typer import TypeInference, DataType\r\n\r\n# Create a type inference instance\r\nti = TypeInference()\r\n\r\n# Single value inference\r\nprint(ti.infer_type('123'))        # DataType.INTEGER\r\nprint(ti.infer_type('1.23'))       # DataType.FLOAT\r\nprint(ti.infer_type('true'))       # DataType.BOOLEAN\r\nprint(ti.infer_type('2023-01-01')) # DataType.DATE\r\n\r\n# Type conversion\r\nprint(ti.convert_value('123'))        # 123 (int)\r\nprint(ti.convert_value('1.23'))       # 1.23 (float)\r\nprint(ti.convert_value('true'))       # True (bool)\r\n```\r\n\r\n### Collection Analysis\r\n\r\n```python\r\n# Analyze collections of values\r\nvalues1 = ['1', '2', '3']\r\nprint(ti.profile_values(values1))  # DataType.INTEGER\r\n\r\nvalues2 = ['1.1', '2.2', '3.3']\r\nprint(ti.profile_values(values2))  # DataType.FLOAT\r\n\r\nvalues3 = ['1', '2.2', 'hello']\r\nprint(ti.profile_values(values3))  # DataType.MIXED\r\n```\r\n\r\n## Supported Data Types\r\n\r\nThe library can infer the following data types:\r\n\r\n- `INTEGER`: Whole numbers (`'123'`, `'-456'`, `'00123'`)\r\n- `FLOAT`: Decimal numbers (`'1.23'`, `'-4.56'`, `'1.0'`)\r\n- `BOOLEAN`: True/false values (`'true'`, `'false'`, `'True'`, `'False'`)\r\n- `DATE`: Date values in various formats (`'2023-01-01'`, `'01/01/2023'`, `'20230101'`)\r\n- `TIME`: Time values (`'14:30:00'`, `'2:30 PM'`, `'143000'`)\r\n- `DATETIME`: Combined date and time (`'2023-01-01T12:00:00'`, `'2023-01-01 12:00:00'`)\r\n- `STRING`: Text data that doesn't match other patterns\r\n- `EMPTY`: Empty strings or whitespace-only strings\r\n- `NONE`: Null values (`'none'`, `'null'`, `None`)\r\n- `MIXED`: Collections containing multiple data types\r\n\r\n## Advanced Usage\r\n\r\n### Handling Edge Cases\r\n\r\n```python\r\n# Leading zeros are handled correctly\r\nprint(ti.infer_type('00123'))  # DataType.INTEGER\r\n\r\n# Invalid dates fall back to string\r\nprint(ti.infer_type('2023-13-01'))  # May be interpreted as date in some formats\r\n\r\n# Mixed collections\r\nmixed_values = ['123', 'abc', '2023-01-01']\r\nprint(ti.profile_values(mixed_values))  # DataType.MIXED\r\n```\r\n\r\n### Performance Considerations\r\n\r\nFor large datasets (>10,000 items), the library automatically enables incremental type checking for better performance:\r\n\r\n```python\r\nlarge_dataset = [str(i) for i in range(50000)]\r\nresult = ti.profile_values(large_dataset)  # Uses optimized incremental processing\r\n```\r\n\r\n## API Reference\r\n\r\n### TypeInference Class\r\n\r\n#### Methods\r\n\r\n- `infer_type(value: str) -> DataType`: Infer type of a single value\r\n- `convert_value(value: Any) -> Any`: Convert value to its inferred type\r\n- `profile_values(values: Iterable[Any]) -> DataType`: Analyze a collection of values\r\n\r\n### String Class\r\n\r\nLow-level string processing utilities:\r\n\r\n- `is_int_like()`, `is_float_like()`, `is_bool_like()`, etc.\r\n- `to_int()`, `to_float()`, `to_bool()`, etc.\r\n- `infer_type()` - direct type inference\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit a Pull Request.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n## Author\r\n\r\nJim Schilling (c) 2025\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Type Inference and Conversion Library for Python",
    "version": "2025.0.1",
    "project_urls": {
        "Changelog": "http://github.com/jim-schilling/splurge-typer/blob/main/CHANGELOG.md",
        "Homepage": "http://github.com/jim-schilling/splurge-typer",
        "Issues": "http://github.com/jim-schilling/splurge-typer/issues",
        "Repository": "http://github.com/jim-schilling/splurge-typer"
    },
    "split_keywords": [
        "type-inference",
        " data-conversion",
        " python",
        " typing",
        " data-processing"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f6aec7621a16ff1eb35f2c0c7771ac9c2162d449d7369a00fda88038f8329fbb",
                "md5": "53cb61e0acb15ce1d7523f7517681ab5",
                "sha256": "11bb09077708762046a0d155fe3a7cb8c377c0899c44af5a445f8c44afb09fd4"
            },
            "downloads": -1,
            "filename": "splurge_typer-2025.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "53cb61e0acb15ce1d7523f7517681ab5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 16624,
            "upload_time": "2025-09-04T21:18:00",
            "upload_time_iso_8601": "2025-09-04T21:18:00.287531Z",
            "url": "https://files.pythonhosted.org/packages/f6/ae/c7621a16ff1eb35f2c0c7771ac9c2162d449d7369a00fda88038f8329fbb/splurge_typer-2025.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "efb10915f6a3bf26f32f11da2e0fb9473cd3c6ab26b4c96e9a8b48adc404824a",
                "md5": "7bab54e2daff6b088334c07bd1ea1aad",
                "sha256": "2f7490dee31eabe113b51f5a861e938a12089fb7e37e0b8f0a51b07c2528a5df"
            },
            "downloads": -1,
            "filename": "splurge_typer-2025.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "7bab54e2daff6b088334c07bd1ea1aad",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 16684,
            "upload_time": "2025-09-04T21:18:01",
            "upload_time_iso_8601": "2025-09-04T21:18:01.446487Z",
            "url": "https://files.pythonhosted.org/packages/ef/b1/0915f6a3bf26f32f11da2e0fb9473cd3c6ab26b4c96e9a8b48adc404824a/splurge_typer-2025.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-04 21:18:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jim-schilling",
    "github_project": "splurge-typer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "splurge-typer"
}
        
Elapsed time: 0.90251s