Skip to main content

VERTICALTABLE structured text parser

Project description

This is an structured text parser.

format

example 1:

source:

[Q] This is a question.
[A] This is an answer.
[Q] This is a question2.
# This is comment
[A] This is an answer2.

parsed:

[
  {
    'Q': 'This is a question.',
    'A': 'This is an answer.',
  },
  {
    'Q': 'This is a question2.',
    'A': 'This is an answer2.',
  },
]
  • If the same key appeared, Next record.

  • Actuary, output is OrderedDict list. Not Dict list.

source:

[Key1]
Value1
[Key2]
Value2
----
[Key3]
Value3
next line
next line
[Key4]

Value4    4!

[Key5]
Value5

parsed:

[
  {
    'Key1': 'Value1',
    'Key2': 'Value2',
  },
  {
    'Key3': 'Value3\nnext line\nnext line',
    'Key4': 'Value4    4!',
    'Key5': 'Value5',
  }
  • Whitespace trimmed.

  • “—-” (Hyphens >= 4) is list separator.

usage

import verticaltable

fp = open('sample.txt')

parsed_list = verticaltable.loads(fp.read())

parsed_list2 = verticaltable.load(open('sample2.txt'))

Project details


Download files

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

Source Distribution

verticaltable-0.1.0.tar.gz (1.7 kB view details)

Uploaded Source

File details

Details for the file verticaltable-0.1.0.tar.gz.

File metadata

File hashes

Hashes for verticaltable-0.1.0.tar.gz
Algorithm Hash digest
SHA256 11b317ba265be7fa10c37383291d52bfdad06c7f447dcfc1547b9672e9904821
MD5 343f3275fd98f78054bea1a76bbd889f
BLAKE2b-256 b038a95766ced9a8cdc41adf0ef547395e67c27a0fd8595a9a84d562166c5018

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page