Parse variable length delimited lines
Project description
xlineparse
Python library to parse variable length delimited lines.
Usage
pip install xlineparse
import datetime as dt
from decimal import Decimal
from typing import Annotated, Literal
import xlineparse as xlp
FooLine = tuple[
Literal["foo"],
int,
Decimal,
Decimal | None,
Annotated[bool, xlp.BoolField(true_value="Y", false_value="F")],
Annotated[dt.date, xlp.DateField(format="%Y-%m-%d")],
Annotated[dt.time, xlp.TimeField(format="%H%M%s")],
]
BarLine = tuple[
Literal["bar"],
int,
]
schema = xlp.Schema.from_type(
delimiter="|",
quote_str=None,
trailing_delimiter=False,
lines=FooLine | BarLine,
)
schema.parse_line("foo|1|3.14||Y|2012-01-02|123200")
# Will return:
(
"foo",
1,
Decimal("3.14"),
None,
True,
dt.date(2012, 1, 2),
dt.time(12, 32, 0),
)
Or directly construct Field
s:
schema = xlp.Schema(
delimiter="|",
quote_str=None,
trailing_delimiter=False,
lines=[
xlp.Line(
name="a",
fields=[
xlp.DecimalField(
required=True,
round_decimal_places=None,
min_value=Decimal("2.0"),
max_value=None,
)
],
)
],
)
assert schema.parse_line("a|2.0")
# Will return:
("a", Decimal("2.0"))
TODO:
- Maybe the big decimals are just floats?
- Allow delimiters to be escaped.
- Can we make enums quicker by moving to Rust?
Install/Develop
uv pip install -e '.[dev]'
maturin develop
Make release
- Add pypi token and user =
__token__
to settings (do this once). - Upversion
pyproject.toml
.
git tag -a v0.0.x head -m v0.0.x
git push origin v0.0.x
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file xlineparse-0.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 657.8 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dff9dae62f339802fa3aa698f08f2bcbcfc1adad51f7eb351ebeff3d017dc26 |
|
MD5 | 9d27d4b879ea1f5777b49951a33fe56c |
|
BLAKE2b-256 | 720ccc74696aee116b06c226e9a421de97ee9ba362050ad2b9fa1eaac729d430 |
File details
Details for the file xlineparse-0.0.6-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 652.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5369069181b5de5f313833fbd661f9754e123c3b0e6901572de9c62402fb8d67 |
|
MD5 | 665897570ebd381dea2d978e22d48f74 |
|
BLAKE2b-256 | a2fd5d91e29589245533a9cd4719636bd54c6473d80535ae221d3d6214b27b18 |
File details
Details for the file xlineparse-0.0.6-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 488.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52d9b53fec7b3f69d3da785f959651d1d0c4033db34ed8f032c7e7185041929f |
|
MD5 | 6aa6d6863961315f24eff6f4af99f779 |
|
BLAKE2b-256 | 37fbd8285d17768f654e459d14438be19e4d2072cb9496b2d2e25ee655e33a0a |
File details
Details for the file xlineparse-0.0.6-cp312-cp312-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp312-cp312-macosx_10_12_x86_64.whl
- Upload date:
- Size: 488.2 kB
- Tags: CPython 3.12, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7f4f8a5f9638003e9a5f56f0d87d76482dc1a5ae19967031a331aa6b03ad488 |
|
MD5 | 740482af3145fa833ef196a3d34b0b78 |
|
BLAKE2b-256 | 35339aca6df117a06c30811b544ca3899c8553dce540d9f15ebbe3dc93a13bc1 |
File details
Details for the file xlineparse-0.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 658.7 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90118783c0bf77c80d7361f51f3626ceb5931637406e334a48e79dfe1c907249 |
|
MD5 | b57978716c28d7417879e875db801daa |
|
BLAKE2b-256 | 37167686cd5130b105f56c9ddc0d3641b43aa8c31c9352cde60639f7d5877ae4 |
File details
Details for the file xlineparse-0.0.6-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 652.7 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bee2ae28cad2441543a0f718f492f7c4a757c5b638168f53e1abd952d12425a6 |
|
MD5 | af5e5d63146cd812787a3fc9bbbe1a69 |
|
BLAKE2b-256 | 75c4eb5cbcc8a75b9d2b68cdc4f92f304443af26fd7080169d193127be38aa9d |
File details
Details for the file xlineparse-0.0.6-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 489.4 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e3086ccf2b41da8594b56f0ad00b5a636090e3894340a1b0f603008ae1d652f |
|
MD5 | 46a41800fb96842639dfcb26737815a7 |
|
BLAKE2b-256 | 92f20a8d3adc5437ffb23403bbefea3e30c7470bfc55a6c036c0131e3e80d760 |
File details
Details for the file xlineparse-0.0.6-cp311-cp311-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp311-cp311-macosx_10_12_x86_64.whl
- Upload date:
- Size: 488.7 kB
- Tags: CPython 3.11, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 873fec527eb9216d36f79564294339d31d93588ac853da1e4b77e20f09b63ec8 |
|
MD5 | 977125911e4b8033ea72eec9a5155cea |
|
BLAKE2b-256 | 44160ebaf1d17fce351616a5bdfafa70c41d110f3115072d0ec014471390a4b1 |
File details
Details for the file xlineparse-0.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 658.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35ef78204ce80616f2f87a42c27cbe8a72b85d3b059eedd5a64f746588ce41cf |
|
MD5 | b1fb36dc0241929769c145b32a1d5f04 |
|
BLAKE2b-256 | 51378ac919f629f40e046c0f35d7be358f81c2a14c6391f1be81b5f365ad006a |
File details
Details for the file xlineparse-0.0.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
- Upload date:
- Size: 652.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ i686, manylinux: glibc 2.5+ i686
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08a8892be1d66806aeab50f559cbecc78ed1a788ce38976923fb7be87a965e4a |
|
MD5 | 2e88fbfd7393d85b85053ff52de17230 |
|
BLAKE2b-256 | 8bab5d788a93687e8cd956634e55657dfa521ae13693cbb8346ebf9b04d21ca9 |
File details
Details for the file xlineparse-0.0.6-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 489.5 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37bbc3698d16b1f7200aefe88c9096cc5d245f8994d2e17c98153b1e3ffbd957 |
|
MD5 | f174e9313382bd05d2af3d6834a5fd2e |
|
BLAKE2b-256 | 433bb67b62d8d1c5de243b7cd8209177a3f8302ec763ca4792f38414ddbf961e |
File details
Details for the file xlineparse-0.0.6-cp310-cp310-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: xlineparse-0.0.6-cp310-cp310-macosx_10_12_x86_64.whl
- Upload date:
- Size: 488.7 kB
- Tags: CPython 3.10, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61ccbe833f1ddf3a430c3235f1b8933c9c9b6b5854b2585e5edcd58628cbb51b |
|
MD5 | 6424bfe22d8e15fef418b9878bab5fbd |
|
BLAKE2b-256 | 9a0c89517897819729ccb581e68a6ac0b87538f082d8ab0234f2b10717e2577c |