Skip to main content

Spec-driven minimalist parser for IHS 297 and 298 formats

Project description

ihs29x

A simple spec-driven streaming ("SAX-style") parser for IHS 297 and 298 files, based on the specifications provided by twoninetyex. It handles 297 and 298 files in either fixed or comma delimited format. In accordance with my reading of the spec, it even handles intermixed formats within a single file, based on (sub-)file headers.

The only interesting function is ihs29x.stream_records, which may be called on an open file-like object in text mode.

Live documentation is available at https://derrickturk.github.io/ihs29x-python/docs/ihs29x.html.

Available under the MIT license.


Usage

For example, try:

import sys

from ihs29x import stream_records


def main(argv: list[str]) -> int:
    if len(argv) != 2:
        print(f'Usage {argv[0]} <298-or-297-file>', file=sys.stderr)
        return 2

    with open(argv[1]) as f:
        for r in stream_records(f):
            print(r)

    return 0


if __name__ == '__main__':
    sys.exit(main(sys.argv))

(c) 2023 terminus, LLC

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

ihs29x-0.1.0.tar.gz (15.0 kB view hashes)

Uploaded Source

Built Distribution

ihs29x-0.1.0-py3-none-any.whl (16.0 kB view hashes)

Uploaded Python 3

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