A small python tool to manipulate Work Item Qury exports to make them re-importable into another Azure DevOps Organization.
| README.md | ||
| reorder_requirements.py | ||
| requirements.pip | ||
Python Azure DevOps Work Item CSV
Run Example
# 1 Create and activate an isolated Python environment
python3 -m venv .venv
source .venv/bin/activate
# 2 Install runtime dependencies
python -m pip install --upgrade pip
python -m pip install -r requirements.pip
# 3 Convert the CSV
python reorder_requirements.py "input.csv" "output.csv"
python reorder_requirements.py -v "/Users/jj/Downloads/input.csv" "/Users/jj/Downloads/output.csv"
Execution Logic Summary
- build_level_map walks up the
Parentchain to assign every row its depth (1, 2, 3, …). - depth_first_order produces a depth-first sequence of IDs so that each parent is immediately followed by its children (and grandchildren).
- restructure creates the empty
IDcolumn plus the mutually-exclusiveTitle 1 – 3columns and appends every other original column (except the oldID,Parent, andTitle). - The script writes the new CSV; nothing is printed except a final “Wrote … rows” confirmation.
You’ll get a file whose first four columns are:
| ID | Title 1 | Title 2 | Title 3 | …other original fields… |
|---|
where:
- Top-level items fill Title 1.
- Second-level items fill Title 2.
- Third-level (and deeper) items fill Title 3.
All hierarchy constraints you specified are enforced automatically. Feel free to adapt the column names or add CLI switches if you ever need variations (e.g., different max depth).