Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for text2py, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size text2py-0.0.2-py3-none-any.whl (4.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size text2py-0.0.2.tar.gz (2.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page