Skip to main content

Python library to manipulate fixed width file (FWF)

Project description

Python FWF

PyPI Version Python CI and PyPI Deploy Python Versions License: MIT Tests pre-commit Coverage

Python library for reading and manipulating fixed-width files (FWF).

Features

  • 📖 Read fixed-width format files with custom column definitions
  • 🔧 Support for typed columns (integer, decimal, date, time, etc.)
  • 📋 Header and footer row handling
  • 🎯 Simple and intuitive API
  • ✅ Fully tested (100% coverage)

Installation

pip install pyfwf

Quick Start

from pyfwf.columns import CharColumn, PositiveIntegerColumn
from pyfwf.descriptors import DetailRowDescriptor, FileDescriptor
from pyfwf.readers import Reader

# Define columns
detail = DetailRowDescriptor([
    CharColumn(name='name', pos=1, size=20),
    PositiveIntegerColumn(name='age', pos=21, size=3),
])

# Create file descriptor
fd = FileDescriptor(line_size=23, details=[detail])

# Read file
with open('data.fwf', 'r') as f:
    reader = Reader(f, fd)
    for row in reader:
        print(row)

Supported Column Types

  • CharColumn - Text data
  • RightCharColumn - Right-aligned text
  • PositiveIntegerColumn - Positive integers
  • PositiveDecimalColumn - Decimal numbers
  • DateColumn - Date values
  • TimeColumn - Time values
  • DateTimeColumn - DateTime values

Documentation

See docs/ for detailed documentation and examples.

License

MIT License © 2015 Umbrella Tech

Author

Kelson da Costa Medeiros kelsoncm@gmail.com

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

pyfwf-1.0.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

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

pyfwf-1.0.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file pyfwf-1.0.0.tar.gz.

File metadata

  • Download URL: pyfwf-1.0.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyfwf-1.0.0.tar.gz
Algorithm Hash digest
SHA256 854ae12db5ae45937ed0fa150f3466945fac54f13e0fb15d6d2231fe6fd17fa7
MD5 7f5c1234aeeeb0edf530ac04b10de58e
BLAKE2b-256 f8e54d45454b7f763a480fc8d8561c0ab9c2b9935cd524b4631f7931840aa00e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfwf-1.0.0.tar.gz:

Publisher: publish.yml on kelsoncm/python-fwf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyfwf-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pyfwf-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyfwf-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f60ecdb032f4a322564a320d24dbcee672866f71442683ae87cacc72a2ef1e7f
MD5 5c64c77e6958f340337206bda2ef023d
BLAKE2b-256 e424d78b36a6af611db6e671c3b4eee87f364c0bcf39f3c91e7abdac4f115869

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyfwf-1.0.0-py3-none-any.whl:

Publisher: publish.yml on kelsoncm/python-fwf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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