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

For use cases check tests folder

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

  • Seismic.SpsParser.Sps21Parser - SPS format version num. SPS 2.1, JAN2006
  • Seismic.VibratorParser.ApsParser
  • Seismic.VibratorParser.CogParser
  • Seismic.VibratorParser.VapsParser

File formats

References

Project details


Download files

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

Files for FixedWidthTextParser, version 0.4.1
Filename, size File type Python version Upload date Hashes
Filename, size FixedWidthTextParser-0.4.1.tar.gz (9.6 kB) File type Source Python version None Upload date Hashes View
Filename, size FixedWidthTextParser-0.4.1-py3-none-any.whl (12.9 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page