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': ' '
},
'date': {
'required': True,
'type': 'date',
'start_pos': 31,
'end_pos': 38,
'alignment': 'left',
'format': '%Y%m%d',
'padding': ' '
},
'decimal': {
'required': True,
'type': 'decimal',
'precision': 2,
'rounding': decimal.ROUND_UP,
'start_pos': 38,
'end_pos': 42,
'alignment': 'left',
'padding': ' '
},
}
Notes:
-
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.
-
A field may not have a default value if it is required.
-
Supported types are string, integer, and decimal.
-
Alignment and padding are required.
License: BSD
Metadata
Release files for FixedWidth 1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| FixedWidth-1.3.tar.gz | 4.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| FixedWidth-1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.8 kB
Release files / FixedWidth-1.3.tar.gz
| Download URL | FixedWidth-1.3.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
472fe49c93dff14975cb8ea5bf6a7ef4c42343a7a1b494993640c6580be3de93
|
|
BLAKE2b-256 checksum How to use checksums |
94b3a6c09d71a822d3570bcc1ec807af99052ef41d6b4606f67340f23933fc54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / FixedWidth-1.3-py3-none-any.whl
| Download URL | FixedWidth-1.3-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
39c3e24067b8436a5ac2560c59bf049a5db324d59271ad297bfd66b18195bf02
|
|
BLAKE2b-256 checksum How to use checksums |
b325987e49efea97bda591282e93a55f86aec6e4fdff5ace77385ed8a5c1b0e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for FixedWidth 1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.