Skip to main content

Data converter

Project description

Data converter

Install

poetry add totype

or

pip install totype

Examples

Transform value

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

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))

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

totype-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

totype-0.1.0-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file totype-0.1.0.tar.gz.

File metadata

  • Download URL: totype-0.1.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.8rc1 Windows/10

File hashes

Hashes for totype-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e8d264a6aebe9f6c3d2b3c097ee53226f42192fd9e9a400941298cdb3f651a6a
MD5 c26373540ef2ca3b105c856890a087ee
BLAKE2b-256 480805cddb21c3d96b239596325d28f165c5ce5ffe30c223f727f2a72605b3be

See more details on using hashes here.

File details

Details for the file totype-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: totype-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.8rc1 Windows/10

File hashes

Hashes for totype-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b87a0cf778bedea51efc7d063d2856b47511992f028972cda524971305ee0958
MD5 2c40cbf8778529482fb425d2292436e9
BLAKE2b-256 79584d5283d7269ddc2211734098ac6746991502d9191788c8e8fc5bcc900dce

See more details on using hashes here.

Supported by

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