Metadata-Version: 2.1
Name: totype
Version: 0.1.0
Summary: Data converter
Home-page: https://github.com/pavelmaksimov/totype
License: Apache-2.0
Keywords: python,data-converter,data-transform
Author: Pavel Maksimov
Author-email: vur21@ya.ru
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Dist: dateutils
Requires-Dist: orjson
Requires-Dist: pendulum
Requires-Dist: simplejson
Requires-Dist: ujson
Project-URL: Repository, https://github.com/pavelmaksimov/totype.git
Description-Content-Type: text/markdown

# Data converter


## Install
    poetry add totype

or

    pip install totype

## Examples

### Transform value

```python
from totype.fields import Field

value = "1"

field = Field(
    transform_funcs=[
        int, 
        lambda x: x * 100,
        str
    ]
)
valid, new_value = field(value)

assert valid
assert new_value == "100"
```


### Transform rows
```python
import datetime as dt
from totype import fields, RowTransform


transform = RowTransform(
    fields=[
        fields.TextField(),
        fields.IntField(),
        fields.UIntField(),
        fields.FloatField(),
        fields.ArrayField(),
        fields.JSONField(),
        fields.DateTimeField(),
        fields.DateField(),
    ],
    skip_error_rows=False,
    store_rows_with_errors=False,
)
newrow = transform(
    (1, "20", "-100", "500", "[[100]]", '{"100": 100}', "2021-01-01", "2021-01-01")
)
assert newrow == ("1", 20, 0, 500.0, [[100]], {"100": 100}, dt.datetime(2021,1,1), dt.date(2021,1,1))
```
