A simple python library for quickly parsing records in a fixed width format.
Project description
SimpleFixedWidth
A simple and very lightweight library for working with fixed width files.
Fixed_Width_Spec
class Field
Signature
Field(number: int, name: int, string: bool, size:int)
- number: int (Positional identifier for the field)
- name: str (Name of the field)
- string: bool (Indicates if the field is a string, if false it is numeric)
- size: int (Length of the field)
Example
Field(5, 'Name', True, 30)
class RecordType
Signature
RecordType(name="", fields=[])
- name: str (Name of the RecordType, if you have more than one)
- fields: list (List of fields for the specification tied to the RecordType)
- field_widths: tuple (Returns tuple of the widths from the fields)
- field_names: list (Returns list of the field names)
Fixed_Width_Record
function get_fields
Slices a string 's' in segments 'args' wide. Negative widths represent ignored padding fields.
Parameters
- s: string
- args: list of widths for the string, negative numbers are skipped
Returns string 's' in a list, minus the skipped fields
function get_line
Takes a string and extracts the record identifier if it exists.
Parameters
- string (String to be sliced into a list of fields)
- rec_type_start=-1 (If the string contains a record identifier, this will start to parse it out)
- rec_type_end=-1 (If the string contains a record identifier, this will end to parse it out)
Returns Tuple of the record identifier and the string it was in.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file SimpleFixedWidth-0.0.1.tar.gz.
File metadata
- Download URL: SimpleFixedWidth-0.0.1.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6645162db503dfd76df5510809705b275fcbccb0fbca93b3eb951df4c3abb885
|
|
| MD5 |
acca36a090a4f73b04e5199481247eb2
|
|
| BLAKE2b-256 |
dc67b0e15083a313fb1d77ee8b3452cb0cc95c2efe67de8c6899100522761c84
|
File details
Details for the file SimpleFixedWidth-0.0.1-py3-none-any.whl.
File metadata
- Download URL: SimpleFixedWidth-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef2e054e6bc0568d75993b7a9de05b48599378f9731ad6ce0c60e72a671ceca9
|
|
| MD5 |
7a74d4166e63190a9f097c6ba84c8afb
|
|
| BLAKE2b-256 |
a801696a0702af1284a2432298b5f5f66e06e5c2dd642f86ba08d98639511a89
|