Version: 0.6.1 Author: Mark L. Short
A specialized, Python-based toolkit for managing, modifying, and analyzing Gary Grigsby's War in the East 2 (WiTE2) CSV data files.
This package is designed for scenario designers and modders who need to perform bulk updates, trace complex upgrade chains, and ensure data integrity across massive game databases without risking file corruption.
The framework is divided into five main sub-packages based on functionality:
- Modifiers: Safely perform bulk data mutations on
_unit,_ob, and_groundCSVs. Uses an atomic file-replacement wrapper to ensure original files are only overwritten if the script completes successfully. - Data Generation & Reporting: Generate scenario insights, map global equipment inventories, trace TOE (Table of Organization and Equipment) upgrade chains, and identify unreferenced "orphan" templates.
- Auditing: Batch evaluate data files for structural integrity, logical consistency, and duplicate IDs. Automatically detects "Ghost Squads" and out-of-bounds map coordinates to prevent game crashes.
- Scanners: High-performance queries to locate specific ground elements, units, or excess logistical stores (e.g., ammo, fuel > 5x need) without modifying the source files.
- Utilities: Memory-efficient CSV streaming generators, robust encoding
detection (
ISO-8859-1), centralized logging, and fast ID-to-string lookup caching using strongly typedIntEnumcolumn mappings.
-
Clone the repository to your local workspace.
-
Install requirements: Ensure you have
pytestinstalled for running the test suite, andchardetfor the encoding detection utility.pip install -r requirements.txt
-
Set Game Data Paths: By default, the toolset expects the standard Steam installation path for WiTE2. The toolkit must resolve the location of your WiTE2 CSV files (e.g., _unit.csv, _ob.csv, _ground.csv). You can configure this in two ways:
- Option A: CLI Configuration (Recommended): Use the config command to save your target directory to a local settings.ini file. This avoids manual code changes.
python -m wite2_tools.cli config --set-path "C:\Path\To\Your\WiTE2\CSV"- Option B: Manual Path Update: Open src\wite2_tools\paths.py and update the GAME_DATA_PATH variable to your specific installation directory.
Always Test on Exported Data First! Before executing any modifiers against your active game data or live mod files, it is highly recommended to experiment in a safe environment:
- Open the WiTE2 Editor.
- Navigate to the CSV Tab and export a fresh copy of your scenario's
data (
_ob.csv,_unit.csv, and_ground.csv) files. - Copy these exported files into this project's local
\datasubdirectory. - Temporarily update your
src\wite2_tools\paths.pyto point to these local files (or use the CLI's optional path arguments) to safely test commands, verify logic, and review the resulting outputs without risking your master game files.
The package provides a unified Command-Line Interface (cli.py) for executing
all tools. Target file paths are resolved automatically via paths.py
unless explicitly overridden via optional arguments.
(Note: Depending on your Windows Python installation, you may need to use py
instead of python in your Command Prompt or PowerShell).
Once installed, you can access the toolkit from your terminal via the unified
command-line interface wite2_tools (or by running the module directly with
python -m wite2_tools.cli).
Tools for generating reports and cross-referencing data.
gen-orphans: Identifies unreferenced (orphaned) TOE(OB) templates and finds units pointing to invalid TOE(OB) IDs. Includes full upgrade-chain tracing.- Example:
python -m wite2_tools.cli gen-orphans --nat-codes 1 3(Filters the scan to Germany(1) and Italy(3) nationality codes).
- Example:
gen-inventory: Generates a comprehensive inventory report of elements.gen-groups: Analyzes and maps organizational groups.gen-chains: Maps and validates unit/TOE(OB) upgrade chains.
Tools for verifying the integrity of your WiTE2 database files.
audit-ground: Scans_ground.csvfor errors.audit-unit: Scans_unit.csvfor broken dependencies or invalid stats.audit-ob: Scans_ob.csvfor malformed templates.audit-batch: Runs a comprehensive audit across multiple target files.
mod-compact-wpn: Compacts weapon data arrays.mod-reorder-ob: Moves a Ground Element to a new slot for a TOE(OB).mod-reorder-unit: Moves a Ground Element to a new slot for a Unit.mod-replace-elem: Batch replaces specific elements within templates.mod-update-num: Updates numerical stats across specified datasets.
Tools for quickly finding specific data points or anomalies.
scan-ob: Locates all Ground Elements matching a WID within OBs.scan-unit: Locates all Ground Elements matching a WID within Units.scan-excess: Locates units with excessive logistical stores.
config: Manage default data directories and settings for the CLI tools.
CLI Examples:
python -m wite2_tools.cli config
python -m wite2_tools.cli config --set-path "C:\DevProjects\wite2_tools\TestMods"
python -m wite2_tools.cli scan-excess --operation fuel
python -m wite2_tools.cli gen-chains --nat-codes 1 3Providing Custom Paths in Windows: If you provide a custom file path that contains spaces, you must wrap it in double quotes for the Windows command line to read it properly:
python -m wite2_tools.cli mod-compact-wpns --ground-file "C:\My WiTE2 Mods\MyCustomMod_ground.csv"This project maintains a robust suite of isolated pytest fixtures. To run
the tests and verify logical consistency before executing on your master game
files:
pytest src\tests\Test data uses mock CSVs generated in a temporary workspace to ensure your actual game files remain untouched during development.
All operations automatically generate a timestamped log file
(e.g., wite2_20260217_1330.log) in the local \logs directory.
Analytical data (like TOE(OB) chains) are saved to the \exports directory.
The toolkit uses a dual-parsing strategy for CSV data:
- Dict-based: Used for files with unique headers for better readability.
- List-based: Used for
_ground.csvand similar files that contain duplicate header strings, ensuring data integrity by using indexed Enums (seewite2_tools.models.GndColumn).