Library for processing structured text into python object (dict or list) using templates
Project description
Library for processing structured text into python object (dict or list) using templates.
Using:
text2py -t template.yml -i input.txt -o output.txt
import text2py
parser = text2py.Parser(template)
output = parser.parse(input_file)
Template format:
Scalar value:
- regexp: 'Volume (?P<volume>\w+) Author (?P<author>\w+)'
key: "{volume}"
value: "{author}"
{volume: author}
Dict value
- regexp: 'Volume (?P<volume>\w+) Author (?P<author>\w+) Review (?P<review>)'
key: "volumes.{volume}"
values:
- key: 'author'
value: "{author}"
- key: 'review'
value: "{review}"
{'volumes' {volume: {'author': author, 'review': review}}}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
text2py-0.0.2.tar.gz
(2.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file text2py-0.0.2.tar.gz.
File metadata
- Download URL: text2py-0.0.2.tar.gz
- Upload date:
- Size: 2.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
174defbf3f552467b19fa644214fcafcee0da06e21174c1c8fa7334befed114d
|
|
| MD5 |
ceafd4dbe7ad150c33bee7a8bd052d88
|
|
| BLAKE2b-256 |
f6c1f28f7416ac459388440ae4db4095bc4db1ab466c86b56479c576ef90a969
|
File details
Details for the file text2py-0.0.2-py3-none-any.whl.
File metadata
- Download URL: text2py-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6eafa8936e4a4ad3924fd22e3426ef1a6b27f61a00062a22ec53063caa65ada
|
|
| MD5 |
ccee3afa85857fdd0c0e5a4c782683a8
|
|
| BLAKE2b-256 |
8a1c4541158ddc78971843e5a65e7d3903c40dccadd3835b6598ccaa74ee4a3f
|