Skip to main content

Professional spreadsheet wrangling utilities for parsing, splitting, and expanding schedule data.

Project description

ScheduleTools

A Python library for parsing, splitting, and expanding schedule data from various formats.

Python 3.8+ License: MIT PyPI version Code style: black

Features

  • ScheduleParser: Parse tab-delimited schedule files with configurable date column names
  • ScheduleSplitter: Split schedule data by groups and apply filters
  • ScheduleExpander: Expand data to include required columns with mappings and defaults
  • CLI Interface: Command-line tools for batch processing
  • Flexible Configuration: JSON-based configuration with inheritance and validation

Installation

pip install scheduletools

Workflow Quick Start

from scheduletools import ScheduleParser, ScheduleSplitter, ScheduleExpander

# 1. Parse schedule data
parser = ScheduleParser("schedule.txt")
parsed_data = parser.parse()

# 2. Split by team
splitter = ScheduleSplitter(parsed_data, "Team")
team_schedules = splitter.split()

# 3. Expand with additional columns
expander = ScheduleExpander(team_schedules["E"], config.json)
expanded_data = expander.expand()

Complete Workflow Example

This example demonstrates the full transformation from wide blocked schedules to long schedules, then expansion and splitting.

Step 1: Parse Block Schedule

Start with a wide blocked schedule format:

Date Time Date Time
6 pm - 7:15 pm 6:00 pm - 7:00 pm 7:00 pm - 8:00 pm 8:15 pm - 9:15 pm
7/21/2025 E / F 7/22/2025 C / D F E
7/28/2025 E / F 7/29/2025 A / B F E
from scheduletools import ScheduleParser

# Parse with default "Date" column and reference date
parser = ScheduleParser("schedule.txt", reference_date="2025-07-21")
parsed_data = parser.parse()

Output - Long Format Schedule:

Index Week Day Date Start Time Duration Team
0 0 Monday 7/21/2025 6:00 PM 1:15 E
1 0 Monday 7/21/2025 6:00 PM 1:15 F
2 0 Tuesday 7/22/2025 6:00 PM 1:00 C
3 0 Tuesday 7/22/2025 6:00 PM 1:00 D
4 0 Tuesday 7/22/2025 7:00 PM 1:00 F
5 0 Tuesday 7/22/2025 8:15 PM 1:00 E
6 1 Monday 7/28/2025 6:00 PM 1:15 E
7 1 Monday 7/28/2025 6:00 PM 1:15 F
8 1 Tuesday 7/29/2025 6:00 PM 1:00 A
9 1 Tuesday 7/29/2025 6:00 PM 1:00 B
10 1 Tuesday 7/29/2025 7:00 PM 1:00 F
11 1 Tuesday 7/29/2025 8:15 PM 1:00 E

Step 2: Expand with Required Fields

from scheduletools import ScheduleExpander

# Configure expansion with required fields, defaults, and mappings
config = {
    "Required": [
        "Date",
        "Time", 
        "Duration",
        "Arrival Time",
        "Name",
        "Location Name",
        "Notes"
    ],
    "defaults": {
        "Name": "On-Ice Practice",
        "Location Name": "PISC",
        "Arrival Time": 15
    },
    "Mapping": {
        "Start Time": "Time",
        "Team": "Notes"
    }
}

expander = ScheduleExpander(parsed_data, config)
expanded_data = expander.expand()

Output - Expanded Schedule:

Date Time Duration Arrival Time Name Location Name Notes
7/21/2025 6:00 PM 1:15 15 On-Ice Practice PISC E
7/21/2025 6:00 PM 1:15 15 On-Ice Practice PISC F
7/22/2025 6:00 PM 1:00 15 On-Ice Practice PISC C
7/22/2025 6:00 PM 1:00 15 On-Ice Practice PISC D
7/22/2025 7:00 PM 1:00 15 On-Ice Practice PISC F
7/22/2025 8:15 PM 1:00 15 On-Ice Practice PISC E
7/28/2025 6:00 PM 1:15 15 On-Ice Practice PISC E
7/28/2025 6:00 PM 1:15 15 On-Ice Practice PISC F
7/29/2025 6:00 PM 1:00 15 On-Ice Practice PISC A
7/29/2025 6:00 PM 1:00 15 On-Ice Practice PISC B
7/29/2025 7:00 PM 1:00 15 On-Ice Practice PISC F
7/29/2025 8:15 PM 1:00 15 On-Ice Practice PISC E

Step 3: Split by Team

from scheduletools import ScheduleSplitter

# Split by the Notes column (which contains team names)
splitter = ScheduleSplitter(expanded_data, "Notes")
team_schedules = splitter.split()

# Show available team keys
print("Available teams:", list(team_schedules.keys()))

Output:

Available teams:'A', 'B', 'C', 'D', 'E', 'F'

Example - Team E Schedule: print(team_schedules['E'])

Date Time Duration Arrival Time Name Location Name Notes
7/21/2025 6:00 PM 1:15 15 On-Ice Practice PISC E
7/22/2025 8:15 PM 1:00 15 On-Ice Practice PISC E
7/28/2025 6:00 PM 1:15 15 On-Ice Practice PISC E
7/29/2025 8:15 PM 1:00 15 On-Ice Practice PISC E

ScheduleParser

Parse tab-delimited schedule files with flexible date column detection.

Input Format

ScheduleParser expects tab-delimited files with blocks starting at rows containing your specified date column name (default: "Date"):

Contents of schedule.txt:

1|Monday      → Tuesday     →                    
2|Date        → Time        → Date         → Time        →             →            
3|            → 6:00–7:15pm →              → 6:00–7:00pm → 7:00–8:00pm → 8:15–9:15pm
4|7/21/2025   → E / F       → 7/22/2025    → C / D       → F           → E
5|7/28/2025   → E / F       → 7/29/2025    → A / B       → F           → E

Note: indicates an inserted tab.

Usage

from scheduletools import ScheduleParser

# Basic usage with default "Date" column name
parser = ScheduleParser("schedule.txt")
data = parser.parse()

# Custom date column name
parser = ScheduleParser("schedule.txt", date_column_name="Day")
data = parser.parse()

# With configuration file
parser = ScheduleParser("schedule.txt", config_path="config.json")
data = parser.parse()

# With config object
config = {"Format": {"Date": "%Y-%m-%d"}}
parser = ScheduleParser("schedule.txt", config=config)
data = parser.parse()

# With custom output column name
config = {"Output": {"value_column_name": "Player"}}
parser = ScheduleParser("schedule.txt", config=config)
data = parser.parse()

Configuration

1|{
2|  "Format": {
3|    "Date": "%m/%d/%Y",
4|    "Time": "%I:%M %p",
5|    "Duration": "H:MM"
6|  },
7|  "Block Detection": {
8|    "date_column_name": "Date"
9|  },
10|  "Missing Values": {
11|    "Omit": true,
12|    "Replacement": "TBD"
13|  },
14|  "Split": {
15|    "Skip": false,
16|    "Separator": ","
17|  },
18|  "Output": {
19|    "value_column_name": "Team"
20|  }
21|}

Configuration Sections

  • Format: Date, time, and duration format specifications
  • Block Detection: Date column name for identifying schedule blocks
  • Missing Values: How to handle empty or missing team entries
  • Split: Team entry splitting configuration (separator, skip options)
  • Output: Output column naming (e.g., "Team", "Player", "Group")

ScheduleSplitter

Split schedule data into multiple DataFrames based on grouping criteria. ScheduleSplitter creates separate DataFrames for each unique combination of values in the specified grouping columns, making it easy to work with subsets of your data.

Basic Usage

from scheduletools import ScheduleSplitter

# Split by single column
splitter = ScheduleSplitter(df, "Team")
team_schedules = splitter.split()

# Split by multiple columns
splitter = ScheduleSplitter(df, ["Team", "Week"])
schedules = splitter.split()

Advanced Usage

from scheduletools import ScheduleSplitter

# With filtering
splitter = ScheduleSplitter(
    df, 
    "Team", 
    include_values=["Team_A", "Team_B"],
    exclude_values=["Team_C"]
)
filtered_schedules = splitter.split()

ScheduleExpander

Expand schedule data to include required columns with mappings and defaults.

Usage

from scheduletools import ScheduleExpander

config = {
    "Required": ["Date", "Time", "Team", "Location", "Status"],
    "defaults": {
        "Location": "Main Arena",
        "Status": "Scheduled"
    },
    "Mapping": {
        "Start Time": "Time"
    }
}

expander = ScheduleExpander(data, config)
expanded_data = expander.expand()

CLI Usage

# Parse schedule
scheduletools parse schedule.txt -o output.csv

# Split data
scheduletools split data.csv --groupby Team -o split/

# Expand data
scheduletools expand data.csv config.json -o expanded.csv

Splitting Data

ScheduleSplitter provides powerful data splitting capabilities:

  • Dictionary Output: Returns a dictionary where keys are group identifiers and values are DataFrames
  • Filtering: Include or exclude specific values using include_values and exclude_values parameters
  • Multi-column Grouping: Split by multiple columns simultaneously for complex data organization

Changelog

0.3.2

  • Renamed CSVSplitter to ScheduleSplitter for better clarity
  • Updated documentation to reflect the new class name
  • Improved class descriptions to emphasize schedule data processing

0.3.0

  • Added configurable date column names (default: "Date")
  • Improved block detection and parsing logic
  • Added config object support for ScheduleParser
  • Removed meta pattern validation, now only validates date column
  • Combined block extraction and processing loops for better performance
  • Enhanced error handling and validation

0.2.0

  • Added configurable block start markers
  • Enhanced block detection strategies
  • Added config object support
  • Improved CLI integration
  • Added comprehensive test coverage

0.1.0

  • Initial release
  • Basic schedule parsing functionality
  • CSV splitting capabilities
  • Data expansion features

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

scheduletools-0.3.3.tar.gz (75.7 kB view details)

Uploaded Source

Built Distribution

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

scheduletools-0.3.3-py3-none-any.whl (48.4 kB view details)

Uploaded Python 3

File details

Details for the file scheduletools-0.3.3.tar.gz.

File metadata

  • Download URL: scheduletools-0.3.3.tar.gz
  • Upload date:
  • Size: 75.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for scheduletools-0.3.3.tar.gz
Algorithm Hash digest
SHA256 3333588cee0f59c34078d5bf89bae5281e7b84d0b6220089c6383bdd8e75faef
MD5 7fdc09079cd2748f1eca073560f095f8
BLAKE2b-256 8de30504317e00202295de985093887e74207f83592b7f9afacc4e2cb3f9b8c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for scheduletools-0.3.3.tar.gz:

Publisher: publish.yml on Khlick/scheduletools

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

File details

Details for the file scheduletools-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: scheduletools-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 48.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for scheduletools-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ccd3735b7b5320dfbe058b5f5090c616e6f452ab594995fbdbf07131ebfd6a9a
MD5 660b4cb139742eeab887ca573870ed65
BLAKE2b-256 9abc5f344c98217fc837d90b88f9f6fd8ed40ab7b2ab5b899b319a7913cf02a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for scheduletools-0.3.3-py3-none-any.whl:

Publisher: publish.yml on Khlick/scheduletools

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