Skip to main content

Fixed width text parser

Project description

Fixed width text parser to array

Parsing different defined text formats to array data

Parser - parse anything according to the format definition

Format definition:

definition = [
    ['FIELD_1', 0, 1, 'string'],
    ['FIELD_2', 1, 10, 'float'],
    ['FIELD_3', 11, 10, 'float'],
    ['FIELD_4', 23, 1, 'integer'],
    ['FIELD_5', 24, 2, 'string'],
    ['FIELD_6', 26, 4, 'integer', 0],
    ['FIELD_7', 30, 4, 'integer', None],
    ['FIELD_8', 34, 4, 'float', None],
    ['FIELD_9', 38, 4, 'float', 0.0],
]

Field definition ['FIELD_6', 26, 4, 'integer', 0]

  • 'FIELD_6' - field name
  • 26 - index of text line where the field starts (count starts from 0)
  • 4 - field length in characters
  • string - field value type (allowed types: string, integer, float)
  • 0 - default value if empty in text line record

For every data type default value is always None if field results as empty string. For every data type it is possible to set default value in format definition.

Specific format parsers

  • Sps21Parser - SPS format version num. SPS 2.1, JAN2006

References

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

FixedWidthTextParser-0.0.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

FixedWidthTextParser-0.0.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file FixedWidthTextParser-0.0.1.tar.gz.

File metadata

  • Download URL: FixedWidthTextParser-0.0.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for FixedWidthTextParser-0.0.1.tar.gz
Algorithm Hash digest
SHA256 6ebf7abe98626e1566dde7008a3475894de2a4f7329bf6e19980f308f7419ee3
MD5 e312c542ce114df4f28af4ecf9ecea95
BLAKE2b-256 5f03ae0a17dadca2cc7c2528c3fe926b9f4556cd663f28d5c1eb10598bb80b47

See more details on using hashes here.

File details

Details for the file FixedWidthTextParser-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: FixedWidthTextParser-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for FixedWidthTextParser-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4af6848bdff1693e6ba0d8adb8ed241763917ce76f3e253698ea88fcceef1eba
MD5 dd4294e65c1bbf678da0202b84096f0a
BLAKE2b-256 e930f60c9e86b29c607390f836f9c7ca062b98d50b124a0b7b2abc85a4713aa8

See more details on using hashes here.

Supported by

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