Anexen / strict-io

Read structured file into pydantic models

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

strict-io

Read structured file into pydantic model(s).

Usage

from enum import Enum
from pydantic import BaseModel
from strict_io.csv import read_csv


class Variety(Enum):
    SETOSA = "Setosa"
    VERSICOLOR = "Versicolor"
    VIRGINICA = "Virginica"


class Iris(BaseModel):
    sepal_width: float
    sepal_length: float
    petal_width: float
    petal_length: float
    variety: Variety


read_csv("iris.csv", Iris)  # Iterable[Iris]

About

Read structured file into pydantic models

License:MIT License


Languages

Language:Python 100.0%