Metadata-Version: 2.4
Name: ssim-parser
Version: 1.0.0
Summary: Comprehensive IATA SSIM file parser with advanced filtering and export
Author-email: "Zhang, Jianchao" <zhangjc@csair.com>
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/zhjch/ssim-parser
Project-URL: Repository, https://github.com/zhjch/ssim-parser
Project-URL: Issues, https://github.com/zhjch/ssim-parser/issues
Keywords: ssim,iata,aviation,airline,schedule,parser,filter
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Office/Business :: Scheduling
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: pandas
Requires-Dist: pandas>=1.0.0; extra == "pandas"
Provides-Extra: parquet
Requires-Dist: pandas>=1.0.0; extra == "parquet"
Requires-Dist: pyarrow>=10.0.0; extra == "parquet"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Dynamic: license-file

# ssim-parser

[![PyPI version](https://badge.fury.io/py/ssim-parser.svg)](https://badge.fury.io/py/ssim-parser)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)

A comprehensive Python parser for IATA SSIM (Standard Schedules Information Manual) flight schedule files (Chapter 7) with advanced filtering capabilities.

## Features

- ✅ Parse SSIM Chapter 7 – Record Types 1, 2, 3, 4, 5
- ✅ Full field coverage for Header, Season, Flight Leg, Segment, Trailer
- ✅ Expand weekly schedules into daily flight lists
- ✅ Advanced filtering:
  - Date range (`--start-date`, `--end-date`)
  - Airlines, departure/arrival stations, flight numbers
  - **Wildcards** (`*`, `?`) and **regular expressions** (prefix `~`)
  - **Exclude** conditions (`--exclude-airlines`, etc.)
- ✅ Export to CSV, JSON, Pandas DataFrame, Parquet
- ✅ Command-line and Python API
- ✅ Statistics: shows filtered counts
- ✅ Strict validation mode
- ✅ Apache 2.0 License (explicit patent grants)

## Installation

```bash
pip install ssim-parser
```

For pandas/parquet support:

```bash
pip install ssim-parser[pandas]      # DataFrame support
pip install ssim-parser[parquet]     # Parquet export
```

## Usage
```bash
ssim-parser -i schedule.ssim -o flights.csv
```

## Filtering Examples
```bash
# Date range and airlines
ssim-parser -i schedule.ssim -o output.csv \
    --start-date 2026-07-01 --end-date 2026-07-31 \
    --airlines UA,AA

# Wildcard: flight numbers starting with "32"
ssim-parser -i schedule.ssim -o output.csv --flight-numbers "32*"

# Regex: airlines starting with 'U'
ssim-parser -i schedule.ssim -o output.csv --airlines "~^U.*"

# Exclude AA and DL
ssim-parser -i schedule.ssim -o output.csv --exclude-airlines AA,DL

# Complex: date + airline + departure + exclusion
ssim-parser -i schedule.ssim -o out.csv \
    --start-date 2026-08-08 --end-date 2026-08-15 \
    --airlines CZ --flight-numbers "327,328" \
    --departure JFK --exclude-arrival LAX
```
## Python API

```python
from ssim_parser import SsimParser, expand_flights, filter_flights

parser = SsimParser()
data = parser.parse_file("schedule.ssim")
all_flights = expand_flights(data)

filtered = filter_flights(
    all_flights,
    start_date="2026-07-01",
    airlines=["UA", "AA"],
    exclude_arrival=["LAX"]
)
print(f"Filtered: {len(filtered)} flights")
```

## Filter Pattern Syntax

+ Exact match: UA

+ Wildcard: * (any sequence), ? (single character)

    - Example: 32* matches 321, 3220, etc.

+ Regular expression: prefix with ~, e.g. ~^UA.* matches all airlines starting with UA.

## Export Formats

+ CSV (default)

+ JSON (-f json)

+ Parquet (-f parquet – requires ssim-parser[parquet])

## Strict Mode
Use --strict to enable validation (throws errors on malformed records).

## Documentation
See the IATA SSIM Manual for field definitions.

## Contributing
Pull requests are welcome. For major changes, please open an issue first.

## License
Apache License 2.0
