Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

gtfs-tools

GTFS cleanup and transformation utilities for improving feed quality and consistency.

Features

  • Clean Feed: Remove problematic Unicode characters (non-breaking spaces, zero-width chars, etc.)
  • Fix Routes: Convert ALL CAPS route names to Title Case using route descriptions as reference
  • Fix Blocks: Clear block_id for trips with overlapping stop times (prevent impossible schedules)
  • Round Shapes: Round geographic coordinates and distances to appropriate precision

Installation

pip install .

Or with development mode:

pip install -e .

Usage

As a Library

from gtfs_normalizer import clean_feed, fix_route_names, fix_overlapping_blocks, round_shapes
from pathlib import Path

feed_dir = Path("feed")

# Clean invisible Unicode whitespace
clean_feed(feed_dir)

# Fix ALL CAPS route names
fix_route_names(feed_dir)

# Fix overlapping block assignments
fix_overlapping_blocks(feed_dir)

# Round geographic/distance values
round_shapes(feed_dir)

As Command-Line Tools

# Clean feed
gtfs-clean ./feed

# Fix route names
gtfs-fix-routes ./feed

# Fix overlapping blocks
gtfs-fix-blocks ./feed

# Round shapes
gtfs-round-shapes ./feed

Module Details

clean_feed

Removes problematic whitespace characters:

  • U+00A0 (non-breaking space)
  • U+200B (zero-width space)
  • U+200C (zero-width non-joiner)
  • U+200D (zero-width joiner)
  • U+FEFF (zero-width no-break space / BOM)

Usage:

from gtfs_normalizer import clean_feed
clean_feed("feed")

fix_route_names

Converts ALL CAPS route names to Title Case using route_desc as reference:

  • Splits route name by " - " separator
  • Finds each part in route_desc (case-insensitive)
  • Reconstructs with proper casing from description
  • Removes route_desc when it duplicates route_long_name

Usage:

from gtfs_normalizer import fix_route_names
fix_route_names("feed")

fix_overlapping_blocks

Clears block_id for trips with overlapping stop times in the same block:

  • Groups trips by block and service
  • Calculates trip start/end times from stop_times
  • Detects overlaps (same physical vehicle in two places simultaneously)
  • Clears block_id for conflicting trips

Usage:

from gtfs_normalizer import fix_overlapping_blocks
fix_overlapping_blocks("feed")

round_shapes

Rounds geographic and distance precision:

  • shapes.txt: lat/lon to 6 decimals (~1.1m accuracy), distances to 2 decimals
  • stop_times.txt: distances to 2 decimals

Usage:

from gtfs_normalizer import round_shapes
round_shapes("feed")

Requirements

  • Python 3.11+
  • No external dependencies

Integration Example

For use in GitHub Actions workflows or local scripts:

import logging
from pathlib import Path
from gtfs_normalizer import clean_feed, fix_route_names, fix_overlapping_blocks, round_shapes

logging.basicConfig(level=logging.INFO)

feed_dir = Path("feed")

# Apply all transformations in sequence
clean_feed(feed_dir)
fix_route_names(feed_dir)
fix_overlapping_blocks(feed_dir)
round_shapes(feed_dir)

print("GTFS feed processing completed")

License

MIT

Release files for gtfs-normalizer 0.0.1.dev1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gtfs-normalizer 0.0.1.dev1
File Size Uploaded
gtfs_normalizer-0.0.1.dev1.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gtfs-normalizer 0.0.1.dev1
File Interpreter ABI Platform
gtfs_normalizer-0.0.1.dev1-py3-none-any.whl Python 3 none any Details

Total release size: 15.1 kB

Release files / gtfs_normalizer-0.0.1.dev1.tar.gz

Download URL gtfs_normalizer-0.0.1.dev1.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8d374727c924f5b0d90900a7f85d0f660f19b616dbe2e4b5c4dc08dc16932059
BLAKE2b-256 checksum
How to use checksums
b2d5aeaf6685ae4e02a71d02fee1f7d3574ef4a4454ac111f2259466759eeedf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / gtfs_normalizer-0.0.1.dev1-py3-none-any.whl

Download URL gtfs_normalizer-0.0.1.dev1-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b175a06d364753f53b4f2214ce5cbeea867fad0ac90c6820b14c9ad52dc02134
BLAKE2b-256 checksum
How to use checksums
1e59415b71e571fe5d3abdec103b92f646b6b310014dc4f61dfa2c2de38e0394
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.0.1.dev1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page