Skip to main content

A library for validating and transforming flat files

Project description

FlatForge

A generic, modular, and extensible library to validate flat files of fixed length or delimited format. This project was created with help of Claude Sonnet 3.7.

Features

  • Validate flat files against predefined schemas
  • Transform flat files from one format to another
  • Support for fixed-length and delimited file formats
  • Extensible rule system for validation and transformation
  • Global rules for cross-record validation
  • CLI interface for easy integration into workflows
  • Support for multi-section files (header, body, footer)
  • Comprehensive error reporting
  • Efficient processing of large files (>1GB) with chunked processing and progress reporting

Installation

pip install flatforge

Quick Start

Command Line Interface

# Validate a file against a schema
flatforge validate --config schema.yaml --input data.csv --output valid.csv --errors errors.csv

# Convert a file from one format to another
flatforge convert --config mapping.yaml --input data.csv --output converted.txt

# Process a large file with chunked processing and progress reporting
flatforge validate --config schema.yaml --input large_data.csv --output valid.csv --errors errors.csv --chunk-size 10000 --show-progress

Programmatic Usage

from flatforge.processors import ValidationProcessor
from flatforge.parsers import ConfigParser

# Parse the configuration
config_parser = ConfigParser.from_file("schema.yaml")
config = config_parser.parse()

# Create a processor
processor = ValidationProcessor(config)

# Process the file
result = processor.process("data.csv", "valid.csv", "errors.csv")
print(f"Processed {result.total_records} records with {result.error_count} errors")

# Process a large file in chunks with progress reporting
def update_progress(processed, total):
    print(f"Progress: {processed}/{total} records ({int(100 * processed / total)}%)")

result = processor.process_chunked(
    "large_data.csv", 
    "valid.csv", 
    "errors.csv", 
    chunk_size=10000, 
    progress_callback=update_progress
)
print(f"Processed {result.total_records} records with {result.error_count} errors")

Documentation

For detailed documentation, please refer to:

Changelog

See the CHANGELOG.md file for details on the changes made in each release.

Contributing

Contributions are welcome! Please see the CONTRIBUTING.md file for guidelines on how to contribute to this project.

Author

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

flatforge-0.3.4.tar.gz (191.9 kB view details)

Uploaded Source

Built Distribution

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

flatforge-0.3.4-py3-none-any.whl (100.7 kB view details)

Uploaded Python 3

File details

Details for the file flatforge-0.3.4.tar.gz.

File metadata

  • Download URL: flatforge-0.3.4.tar.gz
  • Upload date:
  • Size: 191.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for flatforge-0.3.4.tar.gz
Algorithm Hash digest
SHA256 95aa57d231f4628e3c23144968d8a3f1852368eacf337158e67eaea3e43a9041
MD5 3e25dcad983157f0407f909e46ba7694
BLAKE2b-256 16a52ba34a7fd4322a6fad6012f8531448bd9b6fe0a04f959505c60956667390

See more details on using hashes here.

File details

Details for the file flatforge-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: flatforge-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 100.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for flatforge-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ff7f00d13941a8bf2b87883aeddecfd952c13a52dfe4a5a4a055e108271e6d8f
MD5 1e9addbc6655440c4ee86d02dd410925
BLAKE2b-256 b4f63ddbf297d4107a24fb2b4fa3ec06eee279e492367b3bd51d3eb1d9ecd5da

See more details on using hashes here.

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