Skip to main content

yankee_logo Documentation

PyPI PyPI - Python Versions PyPI - Downloads

Summary

Simple declarative data extraction and loading in Python, featuring:

  • 🍰 Ease of use: Data extraction is performed in a simple, declarative types.
  • XML / HTML / JSON Extraction: Extraction can be performed across a wide array of structured data
  • 🐼 Pandas Integration: Results are easily castable to Pandas Dataframes and Series.
  • 😀 Custom Output Classes: Results can be automatically loaded into autogenerated dataclasses, or custom model types.
  • 🚀 Performance: XML loading is supported by the excellent and fast lxml library, JSON is supported by UltraJSON for fast parsing, and jsonpath_ng for flexible data extraction.

Quick Start

To extract data from XML, use this import statement, and see the example below:

from yankee.xml.schema import Schema, fields as f, CSSSelector

To extract data from JSON, use this import statement, and see the example below:

from yankee.xml.schema import Schema, fields as f, JSONPath

To extract data from HTML, use this import statement:

from yankee.html.schema import Schema, fields as f, CSSSelector

To extract data from Python objects (either objects or dictionaries), use this import statement:

from yankee.base.schema import Schema, fields as f

Documentation

Complete documentation is available on Read The Docs

Examples

Extract data from XML

Data extraction from XML. By default, data keys are XPath expressions, but can also be CSS selectors.

Take this:

    <xmlObject>
        <name>Johnny Appleseed</name>
        <birthdate>2000-01-01</birthdate>
        <something>
            <many>
                <levels>
                    <deep>123</deep>
                </levels>
            </many>
        </something>
    </xmlObject>

Do this:

from yankee.xml.schema import Schema, fields as f, CSSSelector

class XmlExample(Schema):
    name = f.String("./name")
    birthday = f.Date(CSSSelector("birthdate"))
    deep_data = f.Int("./something/many/levels/deep")

XmlExample().load(xml_doc)

Get this:

{
    "name": "Johnny Appleseed",
    "birthday": datetime.date(2000, 1, 1),
    "deep_data": 123
}

Extract data from JSON

Data extraction from JSON. By default, data keys are implied from the field names, but can also be JSONPath expressions

Take this:

{
        "name": "Johnny Appleseed",
        "birthdate": "2000-01-01",
        "something": [
            {"many": {
                "levels": {
                    "deep": 123
                }
            }}
        ]
    }

Do this:

from yankee.json.schema import Schema, fields as f

class JsonExample(Schema):
    name = f.String()
    birthday = f.Date("birthdate")
    deep_data = f.Int("something.0.many.levels.deep")

Get this:

{
    "name": "Johnny Appleseed",
    "birthday": datetime.date(2000, 1, 1),
    "deep_data": 123
}

Release files for yankee 0.1.46

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yankee 0.1.46
File Size Uploaded
yankee-0.1.46.tar.gz 88.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yankee 0.1.46
File Interpreter ABI Platform
yankee-0.1.46-py3-none-any.whl Python 3 none any Details

Total release size:192.0 kB

Release files / yankee-0.1.46.tar.gz

Download URL yankee-0.1.46.tar.gz
Size 88.9 kB
Tags Source
SHA-256 checksum
How to use checksums
49fe7255152e8a7766470962e55b002962c016c370e13c4cbfc15f09744ace58
BLAKE2b-256 checksum
How to use checksums
582d0de858d7393eb462c15b8f480abae305d329795e0c2b11ae6cdf058ebdf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Darwin/23.3.0

Release files / yankee-0.1.46-py3-none-any.whl

Download URL yankee-0.1.46-py3-none-any.whl
Size 103.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9932ce72e8fc5146ec9f429f8efb2d204be48996b13fadcfc2df3cffe4520444
BLAKE2b-256 checksum
How to use checksums
b61663f4bbaa035ce9a599031cc20fbd2e39d39d7a5004b605e148973b1b3f7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.4 Darwin/23.3.0

Release history Release notifications | RSS feed

This release

0.1.46 This release

2 release files

0.1.44

2 release files

0.1.43

2 release files

0.1.42

2 release files

0.1.41

2 release files

0.1.40

2 release files

0.1.39

2 release files

0.1.38

2 release files

0.1.37

2 release files

0.1.36

2 release files

0.1.35

2 release files

0.1.31

2 release files

0.1.29

2 release files

0.1.28

2 release files

0.1.27

2 release files

0.1.26

2 release files

0.1.25

2 release files

0.1.24

2 release files

0.1.23

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page