Skip to main content

Two-way fixed-width / Python dict converter.

Project description

Easy two-way conversion between Python dictionaries and fixed-width files. The FixedWidth class has been used in production without modification for several years.

This module has also proven useful for “debugging” a fixed-width spec – an invalid configuration reports an error that may not be obvious from reading the spec document.

Requires a ‘config’ dictonary. See unit tests for full example.

Small example:

SAMPLE_CONFIG = {

    'first_name': {
        'required': True,
        'type': 'string',
        'start_pos': 1,
        'end_pos': 10,
        'alignment': 'left',
        'padding': ' '
    },

    'last_name': {
        'required': True,
        'type': 'string',
        'start_pos': 11,
        'end_pos': 30,
        'alignment': 'left',
        'padding': ' '
    },

}

Notes:

  1. A field must have a start_pos and either an end_pos or a length. If both an end_pos and a length are provided, they must not conflict.
  2. A field may not have a default value if it is required.
  3. Supported types are string, integer, and decimal.
  4. Alignment and padding are required.

Project details


Release history Release notifications

History Node

1.0

History Node

0.99.7

This version
History Node

0.99.3

History Node

0.99

History Node

0.12

History Node

0.11

History Node

0.9

History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
FixedWidth-0.99.3.tar.gz (3.5 kB) Copy SHA256 hash SHA256 Source None Jan 25, 2016

Supported by

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